You are viewing the documentation for Blueriq 16. Documentation for other versions is available in our documentation directory.
INDEXOF
Returns the index of the first occurrence of a specified substring in a string.
Syntax
INDEXOF ( string , substring ) INDEXOF ( string , substring , startIndex )
Inputs
- string - An attribute of base type string, an expression that results in a string or a constant string value.
- substring - An attribute of base type string, an expression that results in a string or a constant string value.
- startIndex - A (positive) integer value indicating at which character the search for the substring should start (inclusive). This can be either an attribute of base type integer, an expression that results in an integer or a constant integer value.
The first character starts at index 0.
Return type
- integer - the index of the first occurrence of the specified substring or -1 if it is not found
Example
Expression | Result | Type |
---|---|---|
INDEXOF ( "Hello world" , "o" ) | 4 | Integer |
INDEXOF ( "Hello world" , "o" , 5 ) | 7 | Integer |
INDEXOF ( "Hello world" , "a" ) | -1 | Integer |
INDEXOF ( "Hello world" , "o" , 8 ) | -1 | Integer |
INDEXOF ( "Hello world" , "o" , -12 ) | 4 | Integer |
INDEXOF ( "Hello world" , "o" , 50 ) | -1 | Integer |
There is no restriction on the value of startIndex. If it is negative, it has the same effect as if it were zero: this entire string may be searched. If it is greater than the length of this string, it has the same effect as if it were equal to the length of this string: -1 is returned.
Overview
Content Tools