rindex()

Deprecated in 5.0.

Replaced with method lastIndexOf() of the string instance.

rindex(string, substring, position): int

Returns the position of the last occurrence of substring in string up to or before position if specified. All index values are 1-based (i.e. the first character has index 1, not 0).

Table 1. Parameters

string

String

The string which will be examined.

substring

String

The string which we will search for.

position

Integer

The position in string to start searching back from. Optional parameter.

Return

Integer value of the position substring was found at, will return 0 if not found.

println(rindex("abcdabcd","cd")); // Will print "7"
println(rindex("abcdef","cd",2)); // Will print "0"
println(rindex("abcdefabcdef","cd",4)); // Will print "3"