安企 CMS 模板中怎么移除字符串任意位置中的指定字符?
cut
过滤器可以移除字符串任意位置中的指定字符。如移除特殊字符、空格等操作,均可使用 cut
过滤器
使用方法
cut
过滤器的使用方法:
{{ obj|cut:"关键词" }}
比如将 test
中的 s
移除,则可以这么写:
{{ "test"|cut:"s" }}
# 显示结果
tet
示例演示
{{ 15|cut:"5" }}
{{ "Hello world"|cut: " " }}
# 显示结果
1
Helloworld