 | 此模板文件被引用於約866,000個頁面,佔全部頁面的10%。 為了避免造成大規模的影響,所有對此模板文件的編輯應先於沙盒、測試樣例或您的沙盒上測試。 測試後無誤的版本可以一次性地加入此模板文件中,但是修改前請務必於討論頁發起討論。
模板引用數量會自動更新。 |
該模板可以剪去字串首尾的空格和換行(但不影響中間的)。字串應作為第1個參數,如果其中包含半形等號=,則必須指定參數名|1=。
你可以替換引用該模板——即使用{{subst:trim}}時,結果是「乾淨」的。
{{trim|text}} = 移除text首尾的空格。
{{trim| abc}},效果為:abc
{{trim|xyz }},效果為:xyz
{{trim| abc xyz }},效果為:abc xyz
如果字串開頭有換行,而且第一個非空白字符是*、#、:、;,則會在開頭保留一個換行,從而將其作為wikitext列表處理。wikitext表格同理。
字符串處理模板 |
|---|
|
|---|
| 根據數量處理 | | | | {{str right}} | 返回從左向右移除若干個字符後的字符串 | | {{str rightc}} | 返回從後向前指定數量的字符串,如果字符串為空則返回一個參數 | | {{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)的字元。 |
|
|
|
|
|
|