You are viewing the documentation for Blueriq 16. Documentation for other versions is available in our documentation directory.
LASTINDEXOF
Returns the index of the last occurrence of a specified substring in a string.
Syntax
LASTINDEXOF ( string , substring ) LASTINDEXOF ( 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), searching backwards. This can be either an attribute of base type integer, an expression that results in an integer or a constant integer value.
Return type
- integer - the index of the last occurrence of the specified substring or -1 if it is not found
Example
Expression | Result | Type |
---|---|---|
LASTINDEXOF ( "Hello world" , "o" ) | 7 | Integer |
LASTINDEXOF ( "Hello world" , "o" , 6 ) | 4 | Integer |
LASTINDEXOF ( "Hello world" , "a" ) | -1 | Integer |
LASTINDEXOF ( "Hello world" , "o" , 3 ) | -1 | Integer |
LASTINDEXOF ( "Hello world" , "o" , -12 ) | -1 | Integer |
LASTINDEXOF ( "Hello world" , "o" , 50 ) | 7 | Integer |
There is no restriction on the value of startIndex. If it is negative, it has the same effect as if it were zero: -1 is returned since there are no characters before character 0. If startIndex is greater than the length of this string, it has the same effect as if it were equal to the length of this string, so the whole string is searched.
Overview
Content Tools