lastIndexOf: Difference between revisions
Jump to navigation
Jump to search
Verisimilar (talk | contribs) m (Applied Template:MacroFunction) |
No edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{MacroFunction | {{MacroFunction | ||
|name=lastIndexOf | |name=lastIndexOf | ||
|version=1.3b48 | |||
|description= | |description= | ||
Finds the index in a string of the last occurrence of a substring in a string. If the substring does not occur in the string then -1 is returned. The index for the string starts at 0. | Finds the index in a string of the last occurrence of a substring in a string. If the substring does not occur in the string then -1 is returned. The index for the string starts at 0. | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
lastIndexOf(str, substr) | |||
</ | </syntaxhighlight> | ||
|example= | |example= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[lastIndexOf("abcde", "c")] | [lastIndexOf("abcde", "c")] | ||
</ | </syntaxhighlight> | ||
Returns 2 | Returns 2 | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[lastIndexOf("abcde", "z")] | [lastIndexOf("abcde", "z")] | ||
</ | </syntaxhighlight> | ||
Returns -1 | Returns -1 | ||
}} | }} | ||
[[Category:String Function]] | [[Category:String Function]] |
Latest revision as of 17:42, 15 March 2023
lastIndexOf() Function
• Introduced in version 1.3b48
Finds the index in a string of the last occurrence of a substring in a string. If the substring does not occur in the string then -1 is returned. The index for the string starts at 0.
Usage
lastIndexOf(str, substr)
Example
[lastIndexOf("abcde", "c")]
Returns 2
[lastIndexOf("abcde", "z")]