• 首页
  • 随机
  • 登录
  • 设置
  • 关于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
  • 免责声明
  • 桌面版