after_regex

Returns a string which is the subset of haystack after the match to the regular expression pattern and not including the matched pattern itself.

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

{{after_regex text pattern flags="t"}}

Arguments

haystack
The input string.

pattern
A valid regular expression.

flags

  • t: trim the final result prior to returning (remove all whitespace from beginning and end)

Examples

Return text after first match of pattern (assuming email.body contains "This is red and that is blue and that is green.")

{{after_regex email.body '/that/' flags='t'}}
is blue and that is green

Return text after last match of pattern (assuming email.body contains "This is red and that is blue and that is green.")

{{after_regex email.body '/that/' flags='tr'}}
is green

Return an empty string if no match of pattern (assuming email.body contains "This is red and that is blue and that is green.")

{{after_regex email.body '/pizza/' flags='t'}}

        
				
			
Updated on May 23, 2024
Was this article helpful?

Related Articles

Need Support?
Can't find the answer you're looking for?
Contact Support