出自Local Chinese Wikipedia
跳至導覽
跳至搜尋
| 警告 | 此模板被引用於約337,000個頁面,佔全部頁面的7%。 為了避免造成大規模的影響,所有對此模板的編輯應先於沙盒、測試樣例或您的沙盒上測試。 測試後無誤的版本可以一次性地加入此模板中,但是修改前請務必於討論頁發起討論。
模板引用數量會自動更新。 |
本模板用於截取字符串的前n個字符。
使用方式[編輯]
|1= — 待截取的字符串
|2= — 截取的字數(默認為1)
{{Str left|底事崑崙傾砥柱?九地黃流亂注,聚萬落千村狐兔!|7}} → 底事崑崙傾砥柱
{{Str left|一二三四五}} → 一
模板數據[編輯]
<templatedata>
{
"description": "顯示一串文字中的前幾個字",
"params": {
"1": {
"label": "文字串",
"description": "需要計算字數裁切的文字內容",
"required": true,
"type": "string"
},
"2": {
"label": "長度",
"description": "希望顯示的字數",
"required": true,
"type": "number"
}
}
}
</templatedata>
字符串處理模板 |
|---|
|
|---|
| 根據數量處理 | | | | {{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)的字元。 |
|
|
|
|
|
|