Template:Str replace

From Disney•Pixar CARS Wiki
Jump to navigation Jump to search
Template:Str replace
{{Str replace
|str=
|pattern=
|return=
}}
Help

Basic use of the {{#rreplace:}} parser function—provided by Extension:RegexFunctions —to perform a text replacement on any given string by way of regular expression. This template alleviates an unusual markup quirk, which normally can be hard to recognize and/or remember: Whitespace cannot exist between parameters as typical, without interfering with processing of the intended pattern.

Parameters
string$strString to be modified
string$patternRegex pattern to perform. The instructions (mostly correctly) imply 1:1 patterns will always work, however don't account for | and other elements of {{}} curly bracket syntax needing to be escaped by way of template substitution i.e. {{!}}.
string$returnFinal string. $1 (etc.) can be used to access capture group(s). \ Backslash escapes are not needed compared to the former.
Returns
string

Used by