That successfully extracts two dates from an email e.g. “22 May 2026 - 26 May 2026” and now I’d like to extend it to also extract a word that follows those two dates. I’m happy with the regexp and understand that I need to use regex_findall and groups but don’t know how to assign the found matches to variables.
I believe the regex_findall call will be as follows:
If the text in the email is going to be simple like that, you really don’t need to do another full regex, you can just split by the end string and index select:
Copy-paste this into the Template Editor and experiment with it.
{% set text = 'bla bla bla 22 May 2026 - 26 May 2026 School bla bla bla' %}
{% set x = text | regex_findall("(\d+ \w+ \d+) - (\d+ \w+ \d+) (\w+)") | flatten %}
{{ x[0] }}
{{ x[1] }}
{{ x[2] }}