Dplreplace: Difference between revisions
Content added Content deleted
imported>FrozenPlum m (separate the examples) |
miraheze:dpl3>Soukupmi (→Examples: breaking example 2 into 2 separate ones) |
||
Line 20: | Line 20: | ||
</pre> |
</pre> |
||
Replaces "ab" with "AB". |
Replaces "ab" with "AB". |
||
'''Result:'''<br> |
'''Result:'''<br> |
||
Line 28: | Line 27: | ||
'''Example 2:''' |
'''Example 2:''' |
||
<pre> |
<pre> |
||
{{#dplreplace:abrakadabra|/a(.*?)r/|A\ |
{{#dplreplace:abrakadabra|/a(.*?)r/|A\1r}} |
||
</pre> |
</pre> |
||
Replaces "a" by "A" if there is an "r" somewhere after the "a". |
Replaces "a" by "A" if there is an "r" somewhere after the "a". The "\1r" part is needed to put back the original text into the replaced string.<br> |
||
<code><nowiki>{{#dplreplace:abrakadabra|/a(.*?)r/|A}}</nowiki></code> (without the "\1r") would otherwise lead to "{{#dplreplace:abrakadabra|/a(.*?)r/|A}}". |
|||
⚫ | |||
'''Result:'''<br> |
|||
{{#dplreplace:abrakadabra|/a(.*?)r/|A\1r}} |
|||
'''Example 3:''' |
|||
<pre> |
|||
{{#dplreplace:abrakadabra|/a(.*?)r/|A\1_r_}} |
|||
</pre> |
|||
Replaces "a" by "A" if there is an "r" somewhere after the "a" and also replaces the "r" at the end of the found group(s) by "_r_". |
|||
⚫ | |||
'''Result:'''<br> |
'''Result:'''<br> |