indexOf: Difference between revisions
Jump to navigation
Jump to search
Verisimilar (talk | contribs) (Applied Template:MacroFunction) |
|||
Line 1: | Line 1: | ||
= | {{MacroFunction | ||
|name=indexOf | |||
|proposed=true | |||
|description= | |||
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. | 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= | |||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[h: ind = index(str, substr)] | [h: ind = index(str, substr)] | ||
Line 9: | Line 11: | ||
</source> | </source> | ||
|examples= | |||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[r: indexOf("this is a test", "is")] | [r: indexOf("this is a test", "is")] | ||
Line 25: | Line 26: | ||
</source> | </source> | ||
Returns -1. | Returns -1. | ||
}} | |||
[[Category:String Function]] |
Revision as of 20:03, 8 March 2009
Note: This refers to a proposed change that has not been implemented in the main code base yet.
indexOf() Function
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
[h: ind = index(str, substr)]
[h: ind = index(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")]