Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
很不言自明。例如,我希望两者都test被Test替换:
test
Test
{{ var|replace({"test": 'replaced'}, ignore) }}
replace过滤器被定义为 的包装器strtr,因此没有内置的方法可以做到这一点。
replace
strtr
延长树枝很容易!只需创建一个名为ireplace(或您认为合适的其他名称)的新过滤器,该过滤器在后台使用 str_ireplace。
ireplace
我认为这个功能是用来替换关键字的,而不是做搜索和替换