indexOf: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 6: | Line 6: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
indexOf(str, substr) | indexOf(str, substr) | ||
</ | </syntaxhighlight> | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
indexOf(str, substr, start) | indexOf(str, substr, start) | ||
</ | </syntaxhighlight> | ||
|examples= | |examples= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: indexOf("this is a test", "is")] | [r: indexOf("this is a test", "is")] | ||
</ | </syntaxhighlight> | ||
Returns 2. | Returns 2. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: indexOf("this is a test", "is", 3)] | [r: indexOf("this is a test", "is", 3)] | ||
</ | </syntaxhighlight> | ||
Returns 5. | Returns 5. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: indexOf("this is a test", "x")] | [r: indexOf("this is a test", "x")] | ||
</ | </syntaxhighlight> | ||
Returns -1. | Returns -1. | ||
}} | }} | ||
[[Category:String Function]] | [[Category:String Function]] |
Latest revision as of 16:23, 15 March 2023
indexOf() Function
• Introduced in version 1.3b48
Returns the index of a substring in the specified string. If the substring does not occur within the string then -1 is returned. If you do not specify the index to start at the search begins at the start of the string otherwise it will begin from the position you specify.
Usage
indexOf(str, substr)
indexOf(str, substr, start)
Examples
[r: indexOf("this is a test", "is")]
Returns 2.
[r: indexOf("this is a test", "is", 3)]
Returns 5.
[r: indexOf("this is a test", "x")]