lastIndexOfIgnoreCase (JavaScriptâ„¢)
Gets the index of the last occurrence of a substring ignoring case.
Defined in
String (Standard - JavaScript)Syntax
lastIndexOfIgnoreCase(searchString:string, position:int) : int| Parameters | Description |
|---|---|
| searchString | Substring to be found. |
| position | Position from the last position at which the search starts. Defaults to the last position. |
| Return value | Description |
|---|---|
| int | Position of the substring relative to position 0, or -1 if the substring is not found. |
Usage
This method searches backwards starting from the last position in the string, or the last position minus the second parameter.Examples
(1) This example returns Paris.var cities = new String("Paris Moscow Tokyo Paris");
var n = cities.lastIndexOfIgnoreCase("paris");
if (n >= 0) {
return cities.substring(n)
} else {
return "Paris not found";
}
(2) This example returns Paris Moscow Tokyo Paris.
var cities = new String("Paris Moscow Tokyo Paris");
var n = cities.lastIndexOfIgnoreCase("paris", 5);
if (n >= 0) {
return cities.substring(n)
} else {
return "Paris not found";
}