Skip to content

Instantly share code, notes, and snippets.

View SpacePossum's full-sized avatar
🇺🇦

SpacePossum

🇺🇦
View GitHub Profile
@SpacePossum
SpacePossum / matches.twig
Last active December 19, 2023 13:25
Example how Twig `(not) matches` works
{% set foo = '123' %}
{{ foo matches '/^[\\d]+$/' ? 'Y' : 'N' }}
{{ foo matches not '/^[\\d]+$/' ? 'Y' : 'N' }} {# wrong, does not work! #}
{{ not (foo matches '/^[\\d]+$/') ? 'Y' : 'N' }}
{% set foo = 'abc' %}
{{ foo matches '/^[\\d]+$/' ? 'Y' : 'N' }}
{{ foo matches not '/^[\\d]+$/' ? 'Y' : 'N' }} {# wrong, does not work! #}
{{ not (foo matches '/^[\\d]+$/') ? 'Y' : 'N' }}