indexOf: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(New page: ==Function indexOf== {{ProposedChange}} 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 speci...)
 
Line 1: Line 1:
==Function indexOf==
==Function indexOf==
{{ProposedChange}}
{{ProposedChange}}
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. [[Macros:regular expressions|regular expressions]] can be used in the substring.
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===
===Usage===

Revision as of 03:44, 23 December 2008

Function indexOf

 Note: This refers to a proposed change that has not been implemented in the main code base yet.

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")]

Returns -1.