How to remove leading and trailing spaces or specific characters from a string in the Anqi CMS template?
trim
/trimLeft
/trimRight
Filters can delete string beginning and end spaces and specific characters respectively.
trim
Filters can remove string beginning and end spaces or specific characters;trimLeft
Filters can remove string leading spaces or specific characters;trimRight
Filters can remove string trailing spaces or specific characters.
How to use
trim
How to use filters
# 仅删除空格、换行符
{{obj|trim}}
# 或者 删除指定字符
{{obj|trim:关键词}}
For example, delete strings欢迎使用安企CMS
The beginning and end spaces of the slightest can be written like this:
{{" 欢迎使用安企CMS "|trim}}
# 显示结果
欢迎使用安企CMS
Delete string欢迎使用安企CMS
The beginning and end characters of欢迎CMS
, you can write it like this:
{{"欢迎使用安企CMS"|trim:"欢迎CMS"}}
# 显示结果
使用安企
trim
Filters also support the use in assignment labels (sets), storing the processing results into a variable, such as:
{% set source = "欢迎使用安企CMS(AnQiCMS)" %}
{% set result = source|trim:"欢迎" %}
{{result}}
# 显示结果
使用安企CMS(AnQiCMS)
trimLeft
How to use filters
# 仅删除空格、换行符
{{obj|trimLeft}}
# 或者 删除指定字符
{{obj|trimLeft:关键词}}
For example, delete strings欢迎使用安企CMS
The leading space of , can be written like this:
{{" 欢迎使用安企CMS "|trimLeft}}
# 显示结果
欢迎使用安企CMS
Delete string欢迎使用安企CMS
Leading characters欢迎
, you can write it like this:
{{"欢迎使用安企CMS"|trimLeft:"欢迎"}}
# 显示结果
使用安企CMS
trimLeft
Filters also support the use in assignment labels (sets), storing the processing results into a variable, such as:
{% set source = "欢迎使用安企CMS(AnQiCMS)" %}
{% set result = source|trimLeft:"欢迎" %}
{{result}}
# 显示结果
使用安企CMS(AnQiCMS)
trimRight
How to use filters
# 仅删除空格、换行符
{{obj|trimRight}}
# 或者 删除指定字符
{{obj|trimRight:关键词}}
For example, delete strings欢迎使用安企CMS
The leading space of , can be written like this:
{{" 欢迎使用安企CMS "|trimRight}}
# 显示结果
欢迎使用安企CMS
Delete string欢迎使用安企CMS
Leading characters欢迎
, you can write it like this:
{{"欢迎使用安企CMS"|trimRight:"CMS"}}
# 显示结果
欢迎使用安企
trimLeft
Filters also support the use in assignment labels (sets), storing the processing results into a variable, such as:
{% set source = "欢迎使用安企CMS(AnQiCMS)" %}
{% set result = source|trimRight:")" %}
{{result}}
# 显示结果
欢迎使用安企CMS(AnQiCMS
Sample Demo
{{" 欢迎使用安企CMS(AnQiCMS) "|trim}}
# 显示结果
欢迎使用安企CMS(AnQiCMS)
{{"欢迎使用安企CMS(AnQiCMS)"|trim:"欢迎"}}
# 显示结果
使用安企CMS(AnQiCMS)
{{" 欢迎使用安企CMS(AnQiCMS) "|trimLeft}}
# 显示结果
欢迎使用安企CMS(AnQiCMS)
{{"欢迎使用安企CMS(AnQiCMS)"|trimLeft:"欢迎"}}
# 显示结果
使用安企CMS(AnQiCMS)
{{"欢迎使用安企CMS(AnQiCMS) "|trimRight}}
# 显示结果
欢迎使用安企CMS(AnQiCMS)
{{"欢迎使用安企CMS(AnQiCMS) "|trimRight:") "}}
# 显示结果
欢迎使用安企CMS(AnQiCMS