This function is used by Ignition's Expression language.


Searches for the first occurrence of the substring inside of string. Returns the index of where substring was found, or -1 if it wasn't found. The first position in the string is position 0.


indexOf(string, substring)

  • Parameters

String or LIst object - The string to search through.

This feature was changed in Ignition version 8.1.8:
The object parameter now accepts tuples and lists. 

String substring - The string to search for.

  • Results

String - The index where the substring was first found in the string.

Code Snippet
indexOf("Hamburger", "urge") //Returns 4.
Code Snippet
indexOf("Test", "") //returns 0
Code Snippet
indexOf("Dysfunctional", "fun") //returns 3
Code Snippet
indexOf("Dysfunctional", "marble") //returns -1
Code Snippet
indexOf("banana", "n") //returns 2
  • No labels