标签: twig
我有以下代码:
{% set foo="abcdef" %}
我希望foo函数可以在匹配中运行:
{{ "abcdef" matches '/foo/i' ? 'yes' : 'no' }}
我希望结果是:是的
请帮帮我。谢谢你
答案 0 :(得分:1)
只需使用~进行字符串连接:
~
{{ "abcdef" matches '/' ~ foo ~ '/i' ? 'yes' : 'no' }}