Uses a regular expression (regex) to search a string for a string
pattern and replace it with another. The search is

REReplace(string, regex, substring [, scope]) → returns string

Argument Reference for the REReplace function


Required: Yes
A string or a variable that contains one


Required: Yes
Regular expression to replace.


Required: Yes
A string or a variable that contains one. Replaces substring with the regex match


Required: No
Default: one
* one: Replace the first occurrence of the regular
expression. Default.
* all: Replace all occurrences of the regular expression. Values:
  • one
  • all

Links more information about REReplace

Examples sample code invoking the REReplace function

Strip Characters Using reReplace

This example strips out all characters except a-z and 0-9.

REReplace("test 123!", "[^a-z0-9]", "", "ALL")

Expected Result: test123

Extract Characters Using Back Reference

Uses a back reference: \1 to extract the pattern contained within the parenthesis.

REReplace("123abc456", "[0-9]+([a-z]+)[0-9]+", "\1")

Expected Result: abc

Fork me on GitHub