Extension:RegexFunctions

The RegexFunctions extension provides regular expression based parser functions.

Usage
As of now, this extension defines three parser functions:  ,  , and   :


 * string ( required ) - The text the function uses for the matching.
 * pattern ( required ) - The regular expression to use on the text.
 * then ( optional ) - What to return if the match was successful. $# and \# contain the captured text.  Use ${#}# if you want a group followed by another number.
 * else ( optional ) - What to return if the match was not successful. Defaults to an empty string.
 * then ( optional ) - What to return if the match was successful. $# and \# contain the captured text.  Use <tvar|1>${#}#</> if you want a group followed by another number.
 * else ( optional ) - What to return if the match was not successful. Defaults to an empty string.


 * string ( required ) - The text the function will split.
 * pattern ( required ) - The regular expression to use on the text. No text is captured.
 * piece ( optional ) - The piece to return. Defaults to 0 (the first piece). Negative numbers return pieces starting from the end.  For example, -1 is the last piece.
 * pattern ( required ) - The regular expression to use on the text. No text is captured.
 * piece ( optional ) - The piece to return. Defaults to 0 (the first piece). Negative numbers return pieces starting from the end.  For example, -1 is the last piece.


 * string ( required ) - The text the function will replace.
 * pattern ( required ) - The regular expression to use on the text.
 * replacement ( required ) - The text to replace the matched text with. <tvar|1>$#</> and <tvar|2>\#</> contain the captured text.  Use <tvar|1>${#}#</> if you want a group followed by another number.
 * pattern ( required ) - The regular expression to use on the text.
 * replacement ( required ) - The text to replace the matched text with. <tvar|1>$#</> and <tvar|2>\#</> contain the captured text.  Use <tvar|1>${#}#</> if you want a group followed by another number.

Except for the <tvar|1>string</> parameter, every parameter can be specified either by name or position. For example, <tvar|1> </>. If your wiki's content language is not English, both the English names as well as a translated name may be usable. In addition, every function supports the following named parameters which allow you to modify the behavior of the regex:


 * multiline - If non-empty, <tvar|1> </> and <tvar|2> </> match the start and end of each line, rather than the start and end of the entire string.
 * caseless - If non-empty, the pattern is case-insensitive.
 * ungreedy - If non-empty, <tvar|star> </> and <tvar|plus> </> do not match greedily whereas <tvar|1> </> and <tvar|2> </> match greedily.
 * extended - If non-empty, the regex can contain spaces and inline comments. See the PHP documentation in the pattern help section for more information.
 *  dotall - If non-empty, <tvar|dot> </> matches all characters, including newlines. Normally it does not match newlines.

For example, <tvar|match> </> would result in the output <tvar|out> </> because <tvar|motif> </> matches both uppercase and lowercase <tvar|letter>X</>'s when the caseless modifier is set.

Pattern help
For help on constructing the syntax, please read <tvar|url></> for general help and <tvar|url2></> for an overview of the modifiers.

Delimiters are not required on the pattern in general and should be omitted for readability where possible, but are required if you would like to specify the single-letter modifiers after the pattern.

In this event, the delimiters must be forward slashes (no other delimiter type is supported).