String.indexOfString()

Signature

int indexOfString (String s1, int fromIndex, String s2)

Domain

action, condition

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

NameTypeDescription
s1StringA String to search.
fromIndexintThe index within the derived substring to begin the search. The index is zero-based.
s2StringA String to search for within the derived substring.

Returns

TypeDescription
intThe index within the derived substring of the first occurrence of the specified s2, or -1 if not present.

Cautions

none

Example


int result = String.indexOfString ("This is a test", 2, "is a");

Result is:
result contains: 3