Category: Script / Strings
Since engine version: 8.0 OC
Returns a string in which all regular expression matches are replaced by a replacement string.
string RegexReplace(string text, string regex, string replacement, int flags);
- Source string in which the replacements occur.
- Regular expression in ECMAScript syntax
- New substring by which the regular expression matches will be replaced. Can reference submatches with $1, $2 etc.
- Bitmask of the following values:
Constant Description Regex_CaseInsensitive Regular expression is case insensitive. Regex_FirstOnly Only replace the first match instead of all matches.
Log(RegexReplace("hello world", "(\\w+)\\s(\\w+)", "$2 $1"));
Swaps two words, displaying "world hello".