RegexReplace

Kategorie: Script / Strings
Ab Engineversion: 8.0 OC

Beschreibung

Returns a string in which all regular expression matches are replaced by a replacement string.

Syntax

string RegexReplace(string text, string regex, string replacement, int flags);

Parameter

text:
Source string in which the replacements occur.
regex:
Regular expression in ECMAScript syntax
replacement:
New substring by which the regular expression matches will be replaced. Can reference submatches with $1, $2 etc.
flags:
Bitmask of the following values:
Konstante Beschreibung
Regex_CaseInsensitive Regular expression is case insensitive.
Regex_FirstOnly Only replace the first match instead of all matches.

Beispiel

Log(RegexReplace("hello world", "(\\w+)\\s(\\w+)", "$2 $1"));
Swaps two words, displaying "world hello".
Siehe auch: RegexMatch, RegexSearch, RegexSplit, ReplaceString
Luchs, 2016-09