该模板返回第一个参数的第一个单词。使用|1=用于第一参数,如果该字符串可以含有等号(=)。默认情况下,单词以空格分隔,但是可选参数|sep=可以将分隔符设置为任何字符。
一个参数(以空格作为分隔符):
{{First word|字符串}}
{{First word|1=字符串}}
两个参数(用户定义的字符作为分隔符):
{{First word|字符串|sep=字符}}
{{First word|1=字符串|sep=字符}}
| 代码 |
结果
|
{{First word|張三 李四 王五}} |
张三
|
{{First word|張三}} |
张三
|
{{First word|張三-李四-王五}} |
张三-李四-王五
|
- {{first word|张三-李四-王五|sep=- }} → 张三
- {{first word|34,000,500|sep=, }} → 34
- {{first word|1=长度 = 甲+乙 |sep== }} → 长度
- {{first word|听到了,用户 |sep=, }} → 听到了,用户
字符串处理模板 |
|---|
| | |
|---|
| | 根据数量处理 | | | | {{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)的字元。 |
|
|
|
| | | | |
|