regexreplacefirstexact(
TEXT
,
PATTERN
,
TEMPLATE
)
The regexreplacefirstexact( function replaces the first occurrence of a regular expression pattern with new text.
Parameters
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.
Description
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 alternative capture groups ($1, $2, etc.) in the replacment template.
See Also
- @regex --
- search( --
- batchreplace -- performs multiple find and replace operations on a piece of text.
- batchreplace( -- performs multiple find/replace operations on a piece of text.
- croptext( -- crops text to a specified length. If the text was already shorter than the specified length, it is left unchanged. If it is longer, the text is cut off and an ellipsis is added on the end.
- percentescape( -- encodes specified characters using percent encoding.
- percentunescape( -- decodes text that contains percent encoding.
- regexreplacefirst( -- replaces the first occurrence of a regular expression pattern with new text.
- replace( -- replaces text with new text.
- replacefirst( -- replaces the first occurence of some text with new text.
- replacemultiple( -- replaces multiple words and phrases in a text value.
- sandwich( -- assembles a text item from three smaller items.
- strip( -- strips off leading and trailing blanks and other whitespace (carriage returns, tabs, etc.)
- stripchar( -- extracts characters you don't want from a text item.
- stripdiacriticals( -- strips diacritical marks from text.
- stripprintable( -- strips non-printable characters from text.
- striptoalpha( -- removes everything but alphabetic letters from a text item.
- striptonum( -- removes everything but numeric digits from a text item.
- urldecode( -- decodes text that contains percent encoded characters.
- urlencode( -- converts text into a legal URL (by converting spaces into `%20`). WARNING: THIS FUNCTION IS OBSOLETE.
History
| 10.0 | New | New in this version. |