listFind: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
(One intermediate revision by the same user not shown) | |||
Line 6: | Line 6: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
listFind(list, value) | listFind(list, value) | ||
</ | </syntaxhighlight> | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
listFind(list, value, delim) | listFind(list, value, delim) | ||
</ | </syntaxhighlight> | ||
If delim is not specified then the default value of ',' is used as the value separator in the [[Macros:string list|string list]] | If delim is not specified then the default value of ',' is used as the value separator in the [[Macros:string list|string list]] | ||
|examples= | |examples= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: listFind("This, is, a, test", "is")] | [r: listFind("This, is, a, test", "is")] | ||
</ | </syntaxhighlight> | ||
Returns 1 | Returns 1 | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: listFind("This: is: a: test", "a", ":")] | [r: listFind("This: is: a: test", "a", ":")] | ||
</ | </syntaxhighlight> | ||
Returns 2 | Returns 2 | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: listFind("This, is, a, test", "not")] | [r: listFind("This, is, a, test", "not")] | ||
</ | </syntaxhighlight> | ||
Returns -1 | Returns -1 | ||
}} | }} | ||
[[Category:String List Function]] | [[Category:String List Function]] |
Latest revision as of 23:59, 15 March 2023
listFind() Function
• Introduced in version 1.3b42
Returns the index of the first occurrence of a value in a string list. If the value is not found then -1 is returned.
Usage
listFind(list, value)
listFind(list, value, delim)
If delim is not specified then the default value of ',' is used as the value separator in the string list
Examples
[r: listFind("This, is, a, test", "is")]
Returns 1
[r: listFind("This: is: a: test", "a", ":")]
Returns 2
[r: listFind("This, is, a, test", "not")]