Difference between revisions of "DPL:Manual - dplreplace"
From FollowTheScore
Line 19: | Line 19: | ||
<nowiki> {{#dplreplace:abrakadabra|ab|AB}} </nowiki> returns: {{#dplreplace:abrakadabra|ab|AB}} | <nowiki> {{#dplreplace:abrakadabra|ab|AB}} </nowiki> returns: {{#dplreplace:abrakadabra|ab|AB}} | ||
− | <nowiki> {{#dplreplace:abrakadabra|a(.)|A\1}} </nowiki> returns: {{#dplreplace:abrakadabra|a(.*?r)|A\1}} | + | <nowiki> {{#dplreplace:abrakadabra|/a(.*?r)/|A\1}} </nowiki> returns: {{#dplreplace:abrakadabra|/a(.*?r)/|A\1}} |
+ | |||
+ | The second example only replaces "a" by "A" if there is an "r" somewehre after the "a". | ||
[[Category:DPL Manual]] | [[Category:DPL Manual]] |
Revision as of 07:37, 13 October 2009
Manual | dplreplace |
Syntax
{{#dplreplace:text|pattern|replacement}}
Effect
Replaces the given pattern within the text by replacement.
pattern is a regular expression as defined by php preg_replace().
replacement may contain references to matching parts.
Example
{{#dplreplace:abrakadabra|ab|AB}} returns: ABrakadABra
{{#dplreplace:abrakadabra|/a(.*?r)/|A\1}} returns: AbrAkadabra
The second example only replaces "a" by "A" if there is an "r" somewehre after the "a".