Handlebars regExMatch
Handlebars regExMatch: applies a regular expression (Java regex syntax) to a string and returns the matched text or one capture group.
Next
Runtime verified
Test scripts included
Applies a regular expression (Java regex syntax) to a string and returns the matched text or one capture group. Returns an empty string when nothing matches.
Syntax
{{regExMatch subject pattern group [...options]}}
Returns string.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
subject |
string | Yes | String to search. |
pattern |
string | Yes | The regular expression to apply. |
group |
string | Yes | Name or number of the capture group to return; “0” is the whole match. |
options |
any | No, repeatable | Named boolean flags: explicitCapture, ignoreCase, ignorePatternWhitespace, multiline. |
Example
Tested in a Marketing Cloud Next email on 2026-11-22:
{{regExMatch "abc123" "[0-9]+" "0"}}renders123, as documented.{{regExMatch "save10" "^[A-Z0-9]{5,7}$" "0" ignoreCase=true}}renderssave10, as documented.{{regExMatch "abc" "[0-9]+" "0"}}renders an empty string, as documented.
Show Next test script
Marketing Cloud Next
Works as documented
Every tested call rendered the documented result. Tested 2026-11-22 by rendering in a Marketing Cloud Next email.
See also
- AMPscript
RegExMatch— does a similar job in AMPscript, with a different call shape - Official reference