INDEX_OF

Description

Returns the zero-based index of the first occurrence of substring within string (case-sensitive). Optionally starts searching from index_optional. Returns -1 if not found.

Syntax

INDEX_OF(string, substring, index_optional) -> Integer

Parameters

ParameterData TypeRequiredDescription
stringStringYesThe string to search within.
substringStringYesThe substring to locate.
index_optionalIntegerNoThe starting index for the search (zero-based). Defaults to 0.

Examples

INDEX_OF("Status=OK", "status")
-- Returns -1.
INDEX_OF("Log entry: userID=1234", "userID=")
-- Returns 11.
INDEX_OF("SystemA-12345-Order-ABC", "-", 10)
-- Returns 13. Finds the first occurrence of "-" starting from index 10.