string.lastIndex

This function returns the index of the last instance of substring in the specified input string.

Syntax

string.lastIndex(str, substr)

Arguments

Argument

Type

Description

str

string

Source string

substr

string

Substring for which the index of the last instance needs to be searched for

Returns

Type

Description

int

  • Index of the last instance of substring in the source string
  • -1 if substring is not present in the source string.

Examples

The function string.lastIndex("hello flogo", "flogo") returns 6.