Skip to content

Latest commit

 

History

History
40 lines (33 loc) · 983 Bytes

rindex.adoc

File metadata and controls

40 lines (33 loc) · 983 Bytes

rindex()

Important

Deprecated in 5.0.

Replaced with method lastIndexOf() of the string instance.

rindex(string, substring, position) => Integer

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.

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