Skip to content

Latest commit

 

History

History
38 lines (31 loc) · 978 Bytes

index.adoc

File metadata and controls

38 lines (31 loc) · 978 Bytes

index()

Important

Deprecated in 5.0.

Replaced with method indexOf() of the string instance.

index(string, substring, position) => Integer

Returns the position of the first occurrence of substring in string at or after 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 starting position in the string to begin our search from the left. Optional parameter

Return

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

Example
println(index("abcdef","cd")); //Will print "3"
println(index("abcdef","cd",4)); //Will print "0"
println(index("abcdefabcdef","cd",4)); //Will print "9"