This template will split strings by incoming parameters, and saved one by one using multiple variables, mostly used in templates.
{{Split
|str = String to be split
|ptn = Characters or regular expressions used for splitting, supports formatting inside nowiki tags
|name = Variable prefixes for split sections, default is foo
|reg = When "on", regular mode is enabled.
}}
In which:
{{#var:(n)}} Holds the string obtained by splitting.{{#var:.count}} holds the total number of strings obtained by splitting.{{Split|Hello,world!|,}}
Split 1: {{#var:foo1}}
Split 2: {{#var:foo2}}
Total number of strings obtained by splitting: {{#var:foo.count}}
Split 1: Hello
Split 2: world!
Total number of strings obtained by splitting: 2
{{split|str=a123b456c|ptn%d+|reg=on}}
Split 1: {{#var:foo1}}
Split 2: {{#var:foo2}}
Split 3: {{#var:foo3}}
Total number of strings obtained by splitting: {{#var:foo.count}}
Split 1: p
Split 2: t
Split 3: n
Total number of strings obtained by splitting: 6
{{split|Moegirl+Welcome+pedia! ++to|+|str}}
{{#var:str2}}{{#var:str5}}{{#var:str1}}{{#var:str3}}
Total number of strings obtained by splitting: {{#var:str.count}}
WelcometoMoegirlPedia!
Total number of strings obtained by splitting: 5
(Because of one of the consecutive plus signs, is given an empty string)
Use this template to split a received string in an agreed format in a template, used as multiple parameters. Because it's a template, no examples can be made here.
{{#fornumargs: num |value
|{{split|{{#var:value}}|,}}
{{ruby|{{#var:foo1}}|{{#var:foo2}}}}
}}
</noinclude></noinclude>