Skip to main content
The indexof function reports the zero-based index of the first occurrence of a specified string within an input string. Use this function to find the position of substrings, validate string formats, or extract parts of strings based on delimiter positions.

For users of other query languages

If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.
In Splunk SPL, you might use searchmatch or string manipulation. APL’s indexof provides a direct way to find substring positions.
In ANSI SQL, you use POSITION() or INSTR() to find substring positions. APL’s indexof provides similar functionality with additional parameters.

Usage

Syntax

Parameters

Returns

Returns the zero-based index position of the first occurrence of the lookup string, or -1 if not found.

Use case examples

Find the position of API version indicators in URIs to categorize and analyze API usage patterns.Query
Run in PlaygroundOutputThis query finds the position of API indicators in URIs, helping identify versioned versus unversioned API endpoints.
  • substring: Extracts a substring from a source string. Use this together with indexof to extract parts of strings based on found positions.
  • strlen: Returns the length of a string. Use this with indexof to calculate positions relative to string length.
  • extract: Extracts substrings using regular expressions. Use this when you need pattern matching instead of simple substring positions.
  • split: Splits strings by delimiters. Use this when you want to tokenize rather than find positions.