| Bookshelf Home | Contents | Index | Search | PDF | ![]() ![]() |
Siebel eScript Language Reference > Siebel eScript Commands > String Objects >
lastIndexOf() Method
This method finds the position of the last occurrence of a substring in a string.
Syntax
stringVar.indexOf(substring [, offset])
Parameter Description substring One or more characters to search for offset The position in the string at which to start searching, where 0 represents the first characterReturns
The position of the last occurrence of a substring in a string variable.
Usage
The stringVar.lastIndexOf() function searches the entire substring in a string variable. The substring parameter may be a single character. If offset is given, searching starts at the indicated position. If it is not given, searching starts at the end of the string.
For example:
var string = "what a string";
string.lastIndexOf("a")returns the position of the last
aappearing in the string, which in this example is 5. Similarly,var magicWord = "abracadabra";
var firstB = magicWord.lastIndexOf("b", 7);returns 1, the index of the first
bto be found in the string when starting backward from the eighth character of the string.See Also
Clib.strchr() Method, Clib.strpbrk() Method, charAt() Method, indexOf() Method, and string.replace() Method
| Bookshelf Home | Contents | Index | Search | PDF | ![]() ![]() |
Siebel eScript Language Reference Published: 18 April 2003 |