出自Local Chinese Wikipedia
imported>Xiplus-abot2020年8月18日 (二) 04:43的修訂
(差異) ←上個修訂 | 最新修訂 (差異) | 下個修訂→ (差異)
跳至導覽
跳至搜尋
此模板透過調用String模塊產生重複的字串,重複次數並無限制。
用法:{{loop|重複次數|需重複的字串}}
如果字符串包含等號,則必須在字串前加上「2=」。例如:
- {{loop|9|2==}}顯示=========(必須有「
2=」)
用例:
- {{loop|4|n}}顯示nnnn
- {{loop|25|test}}顯示testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest
- {{#expr:2{{loop|3|*2}}}}顯示16
- {{loop|3|{{CURRENTYEAR}}}}顯示202620262026
模板數據[編輯]
<templatedata>
{
"params": {
"1": {
"label": "重複次數",
"description": "字符串需重複的次數",
"type": "number",
"required": true
},
"2": {
"label": "字符串",
"description": "需重複的字符串",
"type": "string",
"required": true
}
},
"description": "此模板用於產生重複的字符串",
"paramOrder": [
"1",
"2"
]
}
</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)的字元。 |
|
|
|
|
|
|