replace() #

string replace(string input, string pattern, string replacement [, string modifiers = ""])

The function returns a string that is obtained by replacing each non-overlapping substring of the input that matches the given regular expression pattern with an occurrence of the replacement string, respecting the optional modifiers. Supported modifiers are i (caseless), m (multiline), s (single line) and x (extended).

Internally, FLAT uses libpcre.

Examples #

The replacement parameter may use the captured sub-patterns from the pattern parameter with $n or ${n}. Every such $n will be replaced with the text that has been captured by the n’th parenthesized sub-pattern or the empty string if less than n sub-expression were present in the pattern:

See also #