LAST_INDEX_OF

Description

Returns the starting position (zero-based index) of the last occurrence of substring within string. The search is case-sensitive. If end_position_optional is provided, the search considers characters from the start of the string up to the specified end position. Returns -1 if the substring is not found.

Syntax

LAST_INDEX_OF(string, substring, end_position_optional) -> Integer

Parameters

ParameterData TypeRequiredDescription
stringStringYesThe string to search within.
substringStringYesThe substring to locate.
end_position_optionalIntegerNoThe zero-based index indicating the end position for the search. If omitted, searches the entire string.

Examples

LAST_INDEX_OF("ERR_100|DONE|ERR_200|DONE", "ERR_", 8)
 -- Returns 0. Finds "ERR_" at index 0 within the first 8 characters.
LAST_INDEX_OF("Status: Info, Status: Warn", "status")
 -- Returns -1 (no match, case-sensitive).