indexOf: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Added version.)
Line 1: Line 1:
{{MacroFunction
{{MacroFunction
|name=indexOf
|name=indexOf
|proposed=true
|version=1.3b48
|description=
|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.
Line 7: Line 7:
|usage=
|usage=
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: ind = index(str, substr)]
index(str, substr)
[h: ind = index(str, substr, start)]
</source>
<source lang="mtmacro" line>
index(str, substr, start)
</source>
</source>



Revision as of 11:39, 10 March 2009

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

index(str, substr)
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")]
Returns -1.