該模板可以剪去字串首尾的空格(但不影響中間的)。字串應作為第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}} | 檢查一個字串和某一給定長度相比是「更短」、「等長」還是「更長」。 |
|
分析、技術