Please remember to make use of the DML Wiki Manual of Style and Code of Conduct during your stay.

 Actions

Help

Help:Dplreplace

From Dragon Mania Legends (DML) Wiki

Manual dplreplace


This DPL3 module replaces a given pattern withing given text by the given replacement.

Syntax

{{#dplreplace:text|pattern|replacement}}, where:

  • text is whatever text is to be searched within.
  • pattern is a regular expression as defined by php preg_replace().
  • replacement may contain references to matching parts.

Note: If you are not familiar with regular expressions or do not know the specifics of Perl regexp used in PHP, it may be helpful to see:

Examples

Example 1:
This replaces "ab" with "AB". This is the basic usage without using regular expressions as pattern.

{{#dplreplace:abrakadabra|ab|AB}}

Example 2:
This replaces "a" and its following characters until the next "r", with "A". This example uses a regular expression as pattern, indicated by the "/" characters, and is using the lookahead syntax ? to find the "r".

Matches, with the group match in (): "a(br)", "a(kadabr)".

{{#dplreplace:abrakadabra|/a(.*?r)/|A}}

Example 3:
Replaces "a" with "A" if there is an "r" somewhere after the "a". The \1 references the group found between the "a" and "r" and puts it back into the replaced string.

Matches, with the group match in (): "a(br)", "a(kadabr)".

{{#dplreplace:abrakadabra|/a(.*?r)/|A\1}}

Example 4:
Replaces "a" with "A" if there is an "r" somewhere after the "a", and also replaces the "r" at the end of/outside the found group(s) with "_r_".

Matches, with the group match in (): "a(b)r", "a(kadab)r".

{{#dplreplace:abrakadabra|/a(.*?)r/|A\1_r_}}
This Wiki is created by players for other players and is not maintained by, or affiliated with, the game maker (Gameloft).
Cookies help us deliver our services. By using our services, you agree to our use of cookies.