Skip to main content

IndexOf

The IndexOf function returns the first occurrence of a specified text in a string, otherwise UNDEFINED is returned.

Prototype

  IndexOf(String ; Text)

Arguments


String String By value

Argument contains the input string. The Argument can be a literal, encapsulated in single quotes or
the result of an expression or a variable (Studio only).

Text String By value

Argument that contains the sub-string to look for. The Argument can be a literal encapsulated in single
quotes or the result of an expression or a variable (Studio only).

Returns

Number

The first occurrence of Text in String or -1.

Exception

Undefined

Undefined is returned if one of the two arguments is not a valid string.

Examples

IndexOf('this is my string' ; 'is')

This will return 2.

IndexOf($MyText; 'is')

If the variable $MyText has been initialized with "this is my string", it will return 2.