stringToList: Difference between revisions
Jump to navigation
Jump to search
Verisimilar (talk | contribs) m (Added version.) |
No edit summary |
||
Line 6: | Line 6: | ||
|usage= | |usage= | ||
<source lang="mtmacro" | <source lang="mtmacro"> | ||
stringToList(str, pattern) | stringToList(str, pattern) | ||
stringToList(str, pattern, delim) | stringToList(str, pattern, delim) | ||
</source> | </source> | ||
'''Parameters''' | |||
{{param|str|Variable name of a string to convert.}} | |||
{{param|pattern|The pattern to split the line by.}} | |||
{{param|delim|Option delimiter for output. Defaults to ",".}} | |||
|examples= | |examples= | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[stringToList("This is a test", " ")] | |||
[stringToList("1,2,3,4", ",", ":")] | |||
</source> | </source> | ||
Returns | Returns | ||
<source lang="mtmacro"> | |||
This,is,a,test | |||
1:2:3:4 | |||
</source> | |||
}} | }} | ||
[[Category:String List Function]] | [[Category:String List Function]] |
Revision as of 21:26, 23 September 2019
stringToList() Function
• Introduced in version 1.3b48
Converts a string into a string list using a pattern to determine separator between elements. The specified delimiter is used to separate the elements in the Macros:string list if it is specified, otherwise the default value of "," is used. Pattern can be a regular expression.
Usage
stringToList(str, pattern)
stringToList(str, pattern, delim)
Parameters
str
- Variable name of a string to convert.pattern
- The pattern to split the line by.delim
- Option delimiter for output. Defaults to ",".
Examples
[stringToList("This is a test", " ")]
[stringToList("1,2,3,4", ",", ":")]
Returns
This,is,a,test
1:2:3:4