indexOf: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
m (Conversion script moved page indexOf to IndexOf without leaving a redirect: Converting page title to first-letter uppercase)
(No difference)

Revision as of 22:18, 9 February 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")]
Returns -1.