listReplace: Difference between revisions
Jump to navigation
Jump to search
m (Conversion script moved page ListReplace to listReplace: Converting page titles to lowercase) |
No edit summary |
||
Line 6: | Line 6: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
listReplace(list, index, value) | listReplace(list, index, value) | ||
</ | </syntaxhighlight> | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
listReplace(list, index, value, delim) | listReplace(list, index, value, delim) | ||
</ | </syntaxhighlight> | ||
|examples= | |examples= | ||
'''Simple example:''' | '''Simple example:''' | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: listReplace("This, isnt, a , test", 1, "is")] | [r: listReplace("This, isnt, a , test", 1, "is")] | ||
</ | </syntaxhighlight> | ||
Returns {{code|This, is, a, Test}} | Returns {{code|This, is, a, Test}} | ||
'''Example using a [[String List]] with a non-default delimiter:''' | '''Example using a [[String List]] with a non-default delimiter:''' | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: listReplace("This: isnt: a: test", 1, "is", ":")] | [r: listReplace("This: isnt: a: test", 1, "is", ":")] | ||
</ | </syntaxhighlight> | ||
Returns {{code|This: is: a: test}} | Returns {{code|This: is: a: test}} | ||
'''Example using a [[String List]] stored in a variable:''' | '''Example using a [[String List]] stored in a variable:''' | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: ListVar = "This, is, a, great, test"] | [h: ListVar = "This, is, a, great, test"] | ||
[h: ListVar = listReplace(ListVar, 3, "silly")] | [h: ListVar = listReplace(ListVar, 3, "silly")] | ||
[r: ListVar] | [r: ListVar] | ||
</ | </syntaxhighlight> | ||
Returns: {{code|This, is, a, silly, test}} | Returns: {{code|This, is, a, silly, test}} | ||
}} | }} | ||
[[Category:String List Function]] | [[Category:String List Function]] |
Latest revision as of 20:08, 15 March 2023
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