indexOf() | Zoho QEngine Help

indexOf()

In a nutshell
The indexOf() function takes a string and a search string as arguments and returns the index of the first character of the search string's first occurrence in the string. It returns -1 if the search string is not found, and the search is case-sensitive. The return type is Number, and index positions start from 0.

Overview

The indexOf() function takes string and searchString as arguments. It returns the first occurrence index of searchString's first character in the string.

If the searchString is not found in the string, it returns -1.

Notes

Note:

  • Index starts from 0.

  • This function performs a case-sensitive search.

Return Type

  • Number

Syntax

  1. <variable> = <string>.indexOf( <searchString> );

(OR)

  1. <variable> = indexOf( <string>, <searchString>);

(OR)

  1. <variable> = <string>.find(<searchString>);

(OR)

  1. <variable> = find(<string>,<searchString>);
ParameterDescriptionData type
<variable>Variable which will contain the returned index number.NUMBER
<string>The string from which the index number will be returned.TEXT
<searchString>This string's first character's first occurrence will be checked in the string.TEXT

Examples


  1. text="Hello world, welcome to the universe";
  2. firstIndex = text.indexOf("e");             //returns 1