listReplace: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(21 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
= | {{MacroFunction | ||
|name=listReplace | |||
|version=1.3b42 | |||
|description= | |||
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= | |||
<syntaxhighlight lang="mtmacro" line> | |||
listReplace(list, index, value) | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="mtmacro" line> | |||
listReplace(list, index, value, delim) | |||
</syntaxhighlight> | |||
= | |examples= | ||
'''Simple example:''' | |||
<syntaxhighlight lang="mtmacro" line> | |||
< | |||
[r: listReplace("This, isnt, a , test", 1, "is")] | [r: listReplace("This, isnt, a , test", 1, "is")] | ||
</ | </syntaxhighlight> | ||
Returns This, is, a, Test | Returns {{code|This, is, a, Test}} | ||
< | '''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 This: is: a: test | Returns {{code|This: is: a: test}} | ||
'''Example using a [[String List]] stored in a variable:''' | |||
<syntaxhighlight lang="mtmacro" line> | |||
[h: ListVar = "This, is, a, great, test"] | |||
[h: ListVar = listReplace(ListVar, 3, "silly")] | |||
[r: ListVar] | |||
</syntaxhighlight> | |||
Returns: {{code|This, is, a, silly, test}} | |||
}} | |||
[[Category:String List Function]] |
Latest revision as of 23:59, 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