This template is used on approximately 6,900 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them.
Preview message: Transclusion count updated automatically (see documentation). |
This is a documentation subpage for Template:String split. It may contain usage information, categories and other content that is not part of the original template page. |
This template uses Lua: |
Template:String split is a convenience wrapper for the split
function in Module:String2.
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):
{{#invoke:String2 |split |text |separator |index |true/false}}
{{#invoke:String2 |split |txt=text |sep=separator |idx=index |plain=true/false}}
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.