String.lastIndexOfString()

Signature

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

Domain

action, condition

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

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 last occurrence of the specified s2, or -1 if not present.

Cautions

none

Example


int result = String.lastIndexOfString ("This is a test test", 4, "test");

Result is:
result contains: 11