String.indexOfString()
Signature
int indexOfString (String s1, int fromIndex, String s2)
Description
Takes a substring of s1
, starting at fromIndex, then returns the index of the first
occurrence of s2
within the substring. Returns -1 if not present. The Java
equivalent function is: s1.substring(fromIndex).indexOf(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 first occurrence of
the specified s2 , or -1 if not present. |
Example
int result = String.indexOfString ("This is a test", 2, "is a");
Result is:
result contains: 3