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

See for information about regular expressions.


ReplaceRegex(text, exp, pattern)

Enabled For

For a description of the business object categories, see Notes on "Enabled For".

Business Object Category Yes/No
Business Rules: Before-Save Rules Yes
Business Rules: Calculation Rules (After Save, with or without Also Recalculate on Load) Yes
Business Rules: Calculation Rules (Before Save or Always, without Also Recalculate On Load) Yes
Business Rules: Calculation Rules (Before Save or Always, with Recalculate On Load) Yes
Business Rules: Editing Rules Yes
Business Rules: Initialization Rules Yes
Business Rules: Read Only Rules Yes
Business Rules: Required Rules Yes
Business Rules: Validation Rules Yes
Client Expressions Yes
Object Permissions No
Services Yes
Mobile Yes
Quick Actions (except UI Quick Actions) Yes
UI Quick Actions Yes
Reports Yes
Search/Dashboard without field references Yes
Search/Dashboard with field references No


Parameter Description
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.


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

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