Reference > Expressions > Built-in Functions > Regular Expression Functions > ReplaceRegex

ReplaceRegex

Replaces all matches of a regular expression in the specified text with a specified pattern.

 

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions for information about regular expressions.

Syntax

ReplaceRegex(text, exp, pattern)

Enabled for

Search/Dashboard No
Business Rules Yes
Quick Actions Yes
Workflow Objects  
Reports  

Parameters

text The text in which to match.
exp The regular expression to look for in the text.
pattern The pattern with which to replace the regular expression.  Can have references to capture groups.

Return Value

Text value.

Example

$ReplaceRegex("The large dog ran after the small cat.", /\([a-z]\)\( dog .*) \([a-z]+\) cat/,"$3 $2 $1 cat")

This example returns "The small dog ran after the large cat."