String.lastIndexOfString()
Signature
int lastIndexOfString (String s1, int fromIndex, String s2)
Description
Takes the substring of s1
, starting at fromIndex
, then
returns the index of the last occurrence of s2
within the substring. Returns -1 if
not present. The Java equivalent function is: s1.substring(fromIndex).lastIndexOf(s2)
Parameters
Name | Type | Description |
s1 | String | A String to search. |
fromIndex | int | The index within the derived substring to begin the search. The index is zero-based. |
s2 | String | A String to search for within the derived substring. |
Returns
Type | Description |
int | The index within the derived substring of the
last occurrence of the specified s2 , or -1 if not present. |
Example
int result = String.lastIndexOfString ("This is a test test", 4, "test");
Result is:
result contains: 11