string.index

This function returns the index of the first instance of a substring in the input string.

Syntax

string.index(str, substr)

Arguments

Argument

Type

Description

str

string

Source string

substr

string

Substring to be searched for in the source string

Returns

Type

Description

int

  • Number indicating the index of the first instance of substr in str.

  • -1 if substr is not present in str

Examples

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