string replaceRegEx(string $subject, string $search, string $replace[, int $optionflags])

This function returns $subject with all matches of the regular expression $search replaced with $replace.

$optionflags (optional)

0 - set $optionflags to zero for none of the below options (this will case a case-sensitive match)

1 - case-insensitive (default is case-sensitive)

2 - multiline mode; changes the meaning of ^ and $ so they match at the beginning and end, respectively, of any line, and not just the beginning and end of the entire string

4 - single-line mode; changes the meaning of the dot (.) so that it matches every character (instead of every character except \n)

If regular expressions are not needed, then it is recommended that replaceString[No]Case() be used instead.

This function uses the "PCRE regex flavor". PCRE is short for Perl Compatible Regular Expressions. This page describes the syntax of regular expressions in Perl.

This function is supported only in CSE HTML Validator v11.9913 and later.

See also: matchRegEx()

Example

// sets $result to "sharpen(testing)"
$result=replaceRegEx(' blur (testing)', '^\s*blur\s*\(', 'sharpen(')