listReplace: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Verisimilar (talk | contribs) m (Performed an UNDO of the template tag deletion by the previous edit.) |
||
Line 3: | Line 3: | ||
|version=1.3b42 | |version=1.3b42 | ||
|description= | |description= | ||
Replaces the element at the specified index of a [[ | Replaces the element at the specified index of a [[String List]] with a new value. If a delimiter is not specified then the default value of {{code|","}} is used. The index for lists starts at {{code|0}}. | ||
|usage= | |usage= | ||
Line 13: | Line 13: | ||
</source> | </source> | ||
|example | |examples= | ||
'''Simple example:''' | |||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[r: listReplace("This, isnt, a , test", 1, "is")] | [r: listReplace("This, isnt, a , test", 1, "is")] | ||
</source> | </source> | ||
Returns This, is, a, Test | Returns {{code|This, is, a, Test}} | ||
'''Example using a [[String List]] with a non-default delimiter:''' | |||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[r: listReplace("This: isnt: a: test", 1, "is", ":")] | [r: listReplace("This: isnt: a: test", 1, "is", ":")] | ||
</source> | </source> | ||
Returns This: is: a: test | Returns {{code|This: is: a: test}} | ||
'''Example using a [[String List]] stored in a variable:''' | |||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[h: ListVar = "This, is, a, great, test"] | [h: ListVar = "This, is, a, great, test"] | ||
Line 31: | Line 32: | ||
[r: ListVar] | [r: ListVar] | ||
</source> | </source> | ||
Returns: This, is, a, silly, test | Returns: {{code|This, is, a, silly, test}} | ||
}} | }} | ||
[[Category:String List Function]] | [[Category:String List Function]] |
Revision as of 09:16, 30 June 2009
listReplace() Function
• Introduced in version 1.3b42
Replaces the element at the specified index of a String List with a new value. If a delimiter is not specified then the default value of
","
is used. The index for lists starts at 0
.Usage
listReplace(list, index, value)
listReplace(list, index, value, delim)
Examples
Simple example:
Returns:
[r: listReplace("This, isnt, a , test", 1, "is")]
Returns This, is, a, Test
Example using a String List with a non-default delimiter:
[r: listReplace("This: isnt: a: test", 1, "is", ":")]
Returns This: is: a: test
Example using a String List stored in a variable:
[h: ListVar = "This, is, a, great, test"]
[h: ListVar = listReplace(ListVar, 3, "silly")]
[r: ListVar]
This, is, a, silly, test