Dplreplace

From DynamicPageList3 Manual
Revision as of 08:52, 5 April 2022 by imported>FrozenPlum (separate the examples)
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".

This explanation is incomplete, it needs to be expanded to better explain what is taking place in the result.


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