FirstRegexMatch

Returns the substring of text that is the first match of /regex/.

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

This function can be used to replace the LastWord modifier as used in CSM.

Syntax

FirstRegexMatch(text, exp)

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
LDAP 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

Parameters

Parameter Description
text The text in which to look for the regular expression.
exp The regular expression to look for in the text.

Return Value

Returns a subset of text that is the first match of the regular expression.  Returns null if there is no match.

Example

FirstRegexMatch("Hello there! This is a test, isn't it?", /there.*test/i)

The example above returns "there! This is a test".