regex
Returns a string which is the subset of haystack
that matches the regular expression pattern
.
If no matches to pattern
are present in `haystack`
, returns an empty string.
If pattern
is empty or is an invalid regular expression, throws an exception.
Usage
{{regex haystack pattern flags="t"}}
Arguments
haystack
The input string.
pattern
A valid regular expression.
flags
- r: return the last match to
pattern
and instead of the first match - t: trim the final result prior to returning (remove all whitespace from beginning and end)
Examples
Return the first match to pattern (assuming email.body contains "This is red and that is blue and that is green.")
{{regex email.body '/ is [^r]/' flags='t'}}
is b