Help:Parser functions/rreplace

From Disney•Pixar CARS Wiki
Jump to navigation Jump to search
rreplace
{{#rreplace: string=
|pattern=
|replacement=
|multiline=false
|caseless=false
|ungreedy=false
|extended=false
|dotall=false
}}
Help

Regex text function for replacing a string or substring; akin to PHP preg_replace(), JS replace(), etc.

Source
RegexFunctions
Parameters
string$stringSource text to replace.
string$patternRegex pattern to apply
string$replacementText to replace the matched result. Output captures with \1 or $1 (${1}1 for adjacent literal characters).
boolmultilinePositional anchors ^ and $ should mark boundaries of a single line instead of the full string.
boolcaselessPattern should ignore case (case-insensitive)
boolungreedyMake quantifiers
  • and + match ungreedily when not explicitly prohibited (trailing ?)
boolextendedAllow inline comments
booldotallAllow . to match newlines.
Returns
string Modified or unmodified string (if no changes).