<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh">
	<id>https://arolstar52-zhtest.hf.space/index.php?action=history&amp;feed=atom&amp;title=Template%3AString_split%2Fdoc</id>
	<title>Template:String split/doc - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://arolstar52-zhtest.hf.space/index.php?action=history&amp;feed=atom&amp;title=Template%3AString_split%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://arolstar52-zhtest.hf.space/index.php?title=Template:String_split/doc&amp;action=history"/>
	<updated>2026-06-26T14:10:17Z</updated>
	<subtitle>在这个wiki上该页的修订历史</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://arolstar52-zhtest.hf.space/index.php?title=Template:String_split/doc&amp;diff=3712905&amp;oldid=prev</id>
		<title>imported&gt;Jimmy-bot：​机器人: 尚未清空的已重定向分类） （Cat:String_manipulation_templates→Cat:字符串處理模板</title>
		<link rel="alternate" type="text/html" href="https://arolstar52-zhtest.hf.space/index.php?title=Template:String_split/doc&amp;diff=3712905&amp;oldid=prev"/>
		<updated>2025-01-02T10:21:10Z</updated>

		<summary type="html">&lt;p&gt;机器人: 尚未清空的已重定向分类） （&lt;a href=&quot;/index.php?title=Cat:String_manipulation_templates&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Cat:String manipulation templates（页面不存在）&quot;&gt;Cat:String_manipulation_templates&lt;/a&gt;→&lt;a href=&quot;/index.php?title=Cat:%E5%AD%97%E7%AC%A6%E4%B8%B2%E8%99%95%E7%90%86%E6%A8%A1%E6%9D%BF&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Cat:字符串處理模板（页面不存在）&quot;&gt;Cat:字符串處理模板&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Documentation subpage}}&lt;br /&gt;
{{Lua|Module:String2}}&lt;br /&gt;
&amp;lt;!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --&amp;gt;&lt;br /&gt;
[[Template:String split]] is a convenience wrapper for the &amp;lt;code&amp;gt;split&amp;lt;/code&amp;gt; function in [[Module:String2]].&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;split&amp;lt;/code&amp;gt; function splits text at boundaries specified by separator and returns the chunk for the index idx (starting at 1). It can use positional parameters or named parameters (but these should not be mixed):&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:String2 |split |text |separator |index |true/false}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:String2 |split |txt=text |sep=separator |idx=index |plain=true/false}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
Any double quotes (&amp;quot;) in the separator parameter are stripped out, which allows spaces and wikitext like &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[&amp;quot;[&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; to be passed. Use &amp;lt;code&amp;gt;{{tl|!}}&amp;lt;/code&amp;gt; for the pipe character &amp;lt;code&amp;gt;|&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If the optional plain parameter is set to &amp;lt;code&amp;gt;false / no / 0&amp;lt;/code&amp;gt; then separator is treated as a Lua pattern. The default is plain=true, i.e. normal text matching.&lt;br /&gt;
&lt;br /&gt;
The index parameter is optional; it defaults to the first chunk of text. A negative parameter value counts chunks backward from the end of the text.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{String split |This is a piece of text to be split |&amp;quot; &amp;quot;}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; → {{String split |This is a piece of text to be split |&amp;quot; &amp;quot;}}&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{String split |This is a piece of text to be split |&amp;quot; &amp;quot;| 4}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; → {{String split |This is a piece of text to be split |&amp;quot; &amp;quot;| 4}}&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{String split |This is a piece of text to be split |x| 2}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; → {{String split |This is a piece of text to be split |x| 2}}&lt;br /&gt;
Modules may return strings with | as separators like this: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{#invoke:carousel | main | name = WPDogs | switchsecs = 5 }}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; → {{#invoke:carousel | main | name = WPDogs | switchsecs = 5 }}&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{String split |{{#invoke:carousel | main | name = WPDogs | switchsecs = 5 }}|{{!}}| 2}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; → {{String split |{{#invoke:carousel | main | name = WPDogs | switchsecs = 5 }}|{{!}}| 2}}&lt;br /&gt;
Lua patterns can allow splitting at classes of characters such as punctuation:&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{String split |Apples, pears, oranges; Cats, dogs|&amp;quot;%p&amp;quot;| 2 |false}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; → {{String split |Apples, pears, oranges; Cats, dogs|&amp;quot;%p&amp;quot;| 2 |false}}&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{String split |Apples, pears, oranges; Cats, dogs|&amp;quot;%p&amp;quot;| 4 |false}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; → {{String split |Apples, pears, oranges; Cats, dogs|&amp;quot;%p&amp;quot;| 4 |false}}&lt;br /&gt;
Or split on anything that isn&amp;#039;t a letter (no is treated as false):&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{String split |Apples pears oranges;  Cats  dogs|&amp;quot;%A+&amp;quot;| 4 |no}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; → {{String split |Apples pears oranges;  Cats  dogs|&amp;quot;%A+&amp;quot;| 4 |no}}&lt;br /&gt;
Named parameters force the trimming of leading and trailing spaces in the parameters and are generally clearer when used:&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{String split | txt=Apples pears oranges;  Cats  dogs | sep=&amp;quot;%A+&amp;quot; | idx=3 | plain=false }}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; → {{String split | txt=Apples pears oranges;  Cats  dogs | sep=&amp;quot;%A+&amp;quot; | idx=3 | plain=false }}&lt;br /&gt;
A negative index will count back from the end of the text:&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{String split |txt=This is a piece of text to be split |sep=&amp;quot; &amp;quot; |idx=-1}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; → {{String split |txt=This is a piece of text to be split |sep=&amp;quot; &amp;quot; |idx=-1}}&lt;br /&gt;
An easy mistake to make when using negative parameters is to forget that a trailing space in the text when passed as an unnamed parameter will induce an empty last chunk:&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{String split |This is a piece of text to be split |&amp;quot; &amp;quot;|-1}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; → {{String split |This is a piece of text to be split |&amp;quot; &amp;quot;|-1}}&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{String split |This is a piece of text to be split|&amp;quot; &amp;quot;|-1}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; → {{String split |This is a piece of text to be split|&amp;quot; &amp;quot;|-1}}&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
{{String-handling templates}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;{{sandbox other||&lt;br /&gt;
&amp;lt;!-- Categories below this line, please; interwikis at Wikidata --&amp;gt;&lt;br /&gt;
[[Category:字符串處理模板]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>imported&gt;Jimmy-bot</name></author>
	</entry>
</feed>