Docs »

Developer Guide »

Scripting »

Regular Expressions

You can use regular expressions1 with the regexp filter to match or extract patterns in text:



{% set text = "Your Amazon Order #Z-1234-5678-9 has shipped!" %}
{% set order_id = text|regexp("/Amazon Order #([A-Z0-9\-]+)/", 1) %}
Amazon Order #: {{order_id}}


Amazon Order #: Z-1234-5678-9

References

  1. Wikipedia: Regular Expression - https://en.wikipedia.org/wiki/Regular_expression