این الگو در تعداد زیادی صفحه صفحه بهکار رفته است و تغییر دادن آن میتواند تأثیرات گستردهای داشتهباشد. لطفاً تغییرات را در زیرصفحههای /تمرین یا /آزمایشی الگو، یا در زیرصفحهٔ کاربری خودتان بیازمایید. توصیه میشود که ابتدا در خصوص تغییرات مورد نظر در صفحهٔ بحث گفتگو کرده و سپس آنها را پیادهسازی کنید.
The split 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):
Any double quotes (") in the separator parameter are stripped out, which allows spaces and wikitext like ["[ to be passed. Use {{!}} for the pipe character |.
If the optional plain parameter is set to false / no / 0 then separator is treated as a Lua pattern. The default is plain=true, i.e. normal text matching.
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.
{{String split |This is a piece of text to be split |" "}} → الگو:Stringsplit
{{String split |This is a piece of text to be split |" "| 4}} → الگو:Stringsplit
{{String split |This is a piece of text to be split |x| 2}} → الگو:Stringsplit
Modules may return strings with | as separators like this: {{#invoke:carousel | main | name = WPDogs | switchsecs = 5 }} → خطای اسکریپتی: پودمان «carousel» وجود ندارد.
{{String split |{{#invoke:carousel | main | name = WPDogs | switchsecs = 5 }}|{{!}}| 2}} → الگو:Stringsplit
Lua patterns can allow splitting at classes of characters such as punctuation:
A negative index will count back from the end of the text:
{{String split |txt=This is a piece of text to be split |sep=" " |idx=-1}} → الگو:Stringsplit
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:
{{String split |This is a piece of text to be split |" "|-1}} → الگو:Stringsplit
{{String split |This is a piece of text to be split|" "|-1}} → الگو:Stringsplit