Dplreplace: Difference between revisions
Content added Content deleted
imported>FrozenPlum m (Fix these to have working examples and add a note to come back to this) |
imported>FrozenPlum m (separate the examples) |
||
Line 14: | Line 14: | ||
==Examples== |
==Examples== |
||
'''Example 1:''' |
|||
<pre> |
<pre> |
||
{{#dplreplace:abrakadabra|ab|AB}} |
{{#dplreplace:abrakadabra|ab|AB}} |
||
Line 23: | Line 25: | ||
{{#dplreplace:abrakadabra|ab|AB}} |
{{#dplreplace:abrakadabra|ab|AB}} |
||
'''Example 2:''' |
|||
<pre> |
<pre> |
||
{{#dplreplace:abrakadabra|/a(.*?)r/|A\1_r_}} |
{{#dplreplace:abrakadabra|/a(.*?)r/|A\1_r_}} |
Revision as of 08:52, 5 April 2022
|
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.
Examples
Example 1:
{{#dplreplace:abrakadabra|ab|AB}}
Replaces "ab" with "AB".
Result:
{{#dplreplace:abrakadabra|ab|AB}}
Example 2:
{{#dplreplace:abrakadabra|/a(.*?)r/|A\1_r_}}
Replaces "a" by "A" if there is an "r" somewhere after the "a".
Result:
{{#dplreplace:abrakadabra|/a(.*?)r/|A\1_r_}}