简体   繁体   中英

Remove the '\' from a string in twig

I have this text :

Ch d\`Arnb

Now I want to remove all \\ from string if exist. I try a lot of solutions, one of this : {{ item|replace({'\\/': ''}) }} . But whitout success. Can you help me please ? Thx in advance and sorry for my english.

There is an error in the replace parameter. You are presently trying to remove the / char. Try this:

{% set item = 'Foo\Bar' %}

{{ item|replace({'\\': ''}) }}

Output: FooBar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM