该模板可以剪去字符串首尾的空格(但不影响中间的)。字符串应作为第1个参数,如果其中包含半角等号=
,则必须指定参数名|1=
。
你可以替换引用该模板——即使用{{subst:trim}}
时,结果是“干净”的。
参数及使用方法
模板链接:{{trim|text}}
= 移除text首尾的空格。
示例
- '
模板链接:{{trim| abc}}
',效果为:'abc'
- '
模板链接:{{trim|xyz }}
',效果为:'xyz'
- '
模板链接:{{trim| abc xyz }}
',效果为:'abc xyz'
参见
根据数量处理
| 模板链接:{{str right}} | 返回从左向右移除若干个字符后的字符串 | 模板链接:{{str rightc}} | 返回从后向前指定数量的字符串,如果字符串为空则返回一个参数 | 模板链接:{{str rightmost}} | To trim down to the last specified number of characters. | 模板链接:{{str sub old}} | To trim down to a specified number, starting at a given number from the left. | 模板链接:{{str sub new}} | Select a substr based on starting and ending index. | 模板链接:{{str index}} | 返回字符串的第×个字符 |
|
根据条件处理
专用于Wiki语法
| 模板链接:{{WikiProjectbasename}} | Removes "WikiProject" from a pagename. | 模板链接:{{remove unranked}} | Removes the string "unranked_" from the left of a string (taxonomy). | 模板链接:{{ship prefix}} | Returns the length of a ship's name prefix, if listed (ship names). | 模板链接:{{title year}} | Returns the 4-digit year from a pagename, if any. |
|
插入、替换、长度
模板链接:{{strloc insert}} | Inserts a string at character location strloc, or appends if strloc<=0. | 模板链接:{{loop}} | 特定次数重复字符串。 | 模板链接:{{replace}} | 在字符串中查找并全部替换某字符串后返回。 | 模板链接:{{str rep}} | 在字符串中查找并替换首次出现的某字符串后返回。 | 模板链接:{{digits}} | 移除字符串中不是数字(0~9)的字符。 |
|
模板链接:{{str len}} | 返回字符串长度。 | 模板链接:{{str ≥ len}} | 检查一个字符串和某一给定长度相比是“更长或等长”还是“更短”。 | 模板链接:{{str ≤ len}} | 检查一个字符串和某一给定长度相比是“更短或等长”还是“更长”。 | 模板链接:{{str ≠ len}} | 检查一个字符串和某一给定长度相比是“不等长”还是“等长”。 | 模板链接:{{str ≤ ≥ len}} | 检查一个字符串和某一给定长度相比是“更短”、“等长”还是“更长”。 |
|
分析、技术