The regexreplacefirstexact( function replaces the first occurrence of a regular expression pattern with new text.


This function has three parameters:

text – is the item of text that you want to search through and possibly replace part of.

pattern – is the regular expression that specifies what text should be replaced (see Regular Expressions).

template – is the replacement text, which may include all or portions of the text being replaced.


This function is similar to the replacefirst( function, but uses a regular expression to determine what text to replace (see Regular Expressions).

regexreplacefirst("Now is the time","[a-z]+","redacted") ☞ redacted is the time
regexreplacefirstexact("Now is the time","[a-z]+","redacted") ☞ Nredacted is the time

If the replacement template contains $0, it will be replaced by the found (also called captured) text. This formula uses this technique to surround the matching text with [ and ] brackets.

regexreplacefirstexact("Now is the time","[a-z]+","[$0]") ☞ N[ow] is the time

Note: Unlike the regexreplaceexact( function, this function does not allow multiple pattern/template parameters. It also does not have an options parameter, and is always case sensitive. Use the regexreplacefirst( function if you need case insensitivity. This function also does not allow alternate capture groups ($1, $2, etc.) in the replacment template.

See Also


10.0NewNew in this version.