between_regexs
{{between_regexs text pattern flags="t"}}
Description
Returns a string which is the subset of text between the match to the regular expression start_pattern and the match to the regular expression end_pattern and not including either matched pattern themselves.
If no matches to start_pattern are present in text, returns an empty string.
If no matches to end_pattern are present in text, returns an empty string.
If start_pattern or end_pattern is empty or is an invalid regular expression, throws an exception.
Arguments
text
The input string.
start_pattern
A valid regular expression.
end_pattern
A valid regular expression.
flags
- rsplit text at last match to- start_patternand last match to- end_patterninstead of the first matches
- xexpand located text: use the first match to- start_patternand the last match to- end_pattern
- ttrim the final result prior to returning (remove all whitespace from beginning and end)
Examples
For the following examples, assume that
email.bodycontains:
This is red and that is blue and that is green.
Example 1: Return text between first match to start_pattern and first match to end_pattern
{{between_regexs email.body '/is/' '/is/' flags='t'}}
The above example will output:
red and that
Example 2: Return text between first match to start_pattern and last match to end_pattern (expanded flag)
{{between_regexs email.body '/is/' '/is/' flags='tx'}}
The above example will output:
red and that is blue and that
Example 3: Return text between last match to start_pattern and last match to end_pattern (reverse flag)
{{between_regexs email.body '/is/' '/is/' flags='tr'}}
The above example will output: