模板文档 This template trims matched pairs of leading and trailing single (') and double (") quotes and whitespace from a string. The string should be passed as the first unnamed parameter or using |1=
or |s=
if your string contains any =
signs.
參數及使用方法
{{trim quotes|text}}
= text with any leading or trailing quotes removed (as long as text doesn't contain any =
signs).
{{trim quotes|1=text}}
or {{trim quotes|s=text}}
= text with any leading or trailing square brackets removed.
範例
- <code>
{{trim quotes|1= ""abc's""}}
</code> produces abc's
- <code>
{{trim quotes|1= This is a "quote"}}
</code> produces This is a "quote"
(since the quotes aren't at the beginning and end of the string)
模板編輯說明
模板参数编辑模板数据
参数 | 描述 | 类型 | 状态 |
---|
String | 1 | The string to be trimmed
| 字符串 | 必需 |
---|
參見
字符串處理模板 |
---|
| 切短 |
---|
| 根据数量处理 | {{str mid}} | 按位置及長度選取子串。 | {{trunc}} | 切短到规定的字数。 | {{str left}} | 切短或重复填充到规定的字数。 | {{str crop}} | 從末尾切短特定數量的字元。 | {{chop head and tail}} | To crop a specified number of characters off the beginning and end. |
| {{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)的字元。 |
| {{str len}} | 返回字串長度。 | {{str ≥ len}} | 檢查一個字串和某一給定長度相比是「更長或等長」還是「更短」。 | {{str ≤ len}} | 檢查一個字串和某一給定長度相比是「更短或等長」還是「更長」。 | {{str ≠ len}} | 檢查一個字串和某一給定長度相比是「不等長」還是「等長」。 | {{str ≤ ≥ len}} | 檢查一個字串和某一給定長度相比是「更短」、「等長」還是「更長」。 |
|
|
| | | | |
|