• 首頁
  • 隨機
  • 登入
  • 設定
  • 關於Kyoshihira Encyclopedia
  • 免責聲明
Kyoshihira Encyclopedia

模板:Str ≥ len

  • 語言
  • 監視
  • 檢視原始碼


File:Test Template Info-Icon - Version (2).svg 模板文檔[查看][編輯][歷史][清除快取]
警告此Template被引用於約11,000個頁面。
為了避免造成大規模的影響,所有對此Template的編輯應先於沙盒、測試樣例或您的沙盒上測試。實施修改前,建議先在討論頁發起討論。
模板引用數量會自動更新。

目次

  • 1 模板介紹
  • 2 使用方法
  • 3 範例
  • 4 參見

模板介紹

這是{{Str ≥ len}}元模板。

它可以幫助其他模板檢查一個字符串含有「大於或等於」還是「小於」給定數量的字符。

使用方法

此模板需要3到4個匿名的參數。

詳細參數說明:

{{str ≥ len 
| 1 =被检查的字符串
| 2 =用来比较的长度值
| 3 =“大于或等于”时返回的内容。
| 4 =“小于”时返回的内容。
}}

空或未定義的字符串被認為是長度為0。 低於0的長度值被認為是0。

範例

下面是檢查字符串「abcde」是4個或更多字符的方法:

{{str ≥ len | abcde | 4
| Equal or longer.
| Shorter.
}}

它返回:

Equal or longer.

模板處理包含等號「 = 」的參數數據時會有一個問題。但是,這很容易使用命名編號參數解決。在這裡,我們檢查字符串「ab=cde」是否含有100個或更多字符:

{{str ≥ len 
| 1 = ab=cde 
| 2 = 100
| 3 = Equal "=" or longer.
| 4 = Shorter, not "=".
}}

它返回:

Shorter, not "=".

總是使用命名編號參數可能是一個良好的習慣,因為您可能事先無法確切知道您的模板將把什麼數據傳給元模板。

參見

  • 查
  • 論
  • 編
字符串處理模板
切短(英語:Trimming (computer programming))
根據數量處理
{{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}} 返回字符串的第×個字符
根據條件處理
{{trim}} 移除首尾空格。
{{str letter/trim}} To trim down to the beginning letters.
{{str number/trim}} To trim down to the beginning numbers.
{{trim brackets}} To trim any leading or trailing square brackets.
{{trim quotes}} To trim leading or trailing matches quotes.
{{String split}} 從長字符串中抽取短字符串。
{{first word}} 切短至首個空格前。
{{remove first word}} 移除首個空格前的內容。
{{last word}} 切短至最後一個空格前。
{{remove last word}} 移除最後一個空格前的內容。
專用於Wiki語法
{{除鏈}} 去除Wiki連結的括號(Wiki代碼)。
{{remove file prefix}} 從檔案名中去除「File:」(或「Image:」)。
{{PAGENAMEBASE}} 去除字串末尾的括號文本(消歧義)。
{{title disambig text}} 返回字串末尾的括號文本(消歧義)。
{{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}} 檢查一個字串和某一給定長度相比是「更短」、「等長」還是「更長」。
分析、技術
{{str endswith}} 檢查是否以給定的字符串結尾。
{{str find}}
{{strfind short}}
在一個字串中搜尋並返回特定字串的位置。
{{str find0}} Zero-based substring search.
{{str sub find}} 從指定的偏移量開始搜索一個子字符串。
{{str letter}} 返回一個字符串開頭的所有字符。
{{str number}} 返回一個字符串開頭的所有數字。
{{str gtr str}} 判斷兩個字符串是否相等,然後根據返回相應的值。
{{str match}} 在一個字串中對正則表達式的查詢結果進行分捕獲組的輸出。
{{ASCII code}} 返回單個字符的ASCII碼值
{{a or an}} Takes a noun and produces the appropriate indefinite article, based on whether the first letter is a vowel.
   
Module:String
...Magic words About {{padleft:|}}.
...ParserFunctions About {{#titleparts:|}}, {{#expr:|}}, {{#ifeq:|}}, etc.
  • Category:字符串處理模板
  • m:Category:String templates
  • commons:Category:字符串處理模板
上述文件嵌入自Template:Str ≥ len/doc。(編輯 | 歷史)
編者可以在本模板的沙盒(建立 | 鏡像)和測試樣例(建立)頁面進行實驗。
請在/doc子頁面中添加分類。本模板的子頁面。
取自「http://wiki.kyoshihira.uk/index.php?title=Template:Str_≥_len&oldid=1989」
最後編輯於 2025年6月30日 (星期一) 07:55

語言

  • 不转换
  • 简体
  • 繁體
  • 大陆简体
  • 香港繁體
  • 澳門繁體
  • 大马简体
  • 新加坡简体
  • 臺灣正體
Kyoshihira Encyclopedia
  • 此頁面最後編輯於 2025年6月30日 (星期一) 07:55。
  • 除非另有註明,否則頁面內容基於知识共享署名-非商业性使用-相同方式共享之下可用
  • 隱私權政策
  • 關於Kyoshihira Encyclopedia
  • 免責聲明
  • 桌面版