stringToList: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(New page: ==Function stringToList== Converts a string into a Macros:string list using a pattern to determine separator between elements. The specified delimiter is used to separate the element...)
 
m (Applied Template:MacroFunction)
Line 1: Line 1:
==Function stringToList==
{{MacroFunction
 
|name=stringToList
|description=
Converts a string into a [[Macros:string list|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 [[Macros:regular expression|regular expression]].
Converts a string into a [[Macros:string list|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 [[Macros:regular expression|regular expression]].


===Usage===
|usage=
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: list = stringToList(str,  pattern)]
[h: list = stringToList(str,  pattern)]
Line 9: Line 10:
</source>
</source>


 
|examples=
===Example===
<source lang="mtmacro" line>
<source lang="mtmacro" line>
     [stringToList("This is a test", " ")]
     [stringToList("This is a test", " ")]
Line 18: Line 18:
     This,is,a,test
     This,is,a,test
     1:2:3:4
     1:2:3:4
}}
[[Category:String List Function]]

Revision as of 05:20, 9 March 2009

stringToList() Function

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

[h: list = stringToList(str,  pattern)]
[h: list = stringToList(str, pattern, delim)]

Examples

    [stringToList("This is a test", " ")]
    [stringToList("1,2,3,4", ",", ":")]

Returns

   This,is,a,test
1:2:3:4