Siebel eScript Language Reference > Methods Reference > String Methods >

Search String for Substring Method


The Search String for Substring method searches the stringVar variable for the entire string that you specify in the substring argument. It returns the position of the first occurrence of this string.

If any of the following situations is true, then it returns a value of negative 1:

  • It does not find the value that you specify in the substring argument.
  • The value you specify in the offset argument is outside the range of positions in the string.

Values you enter for arguments are case-sensitive.

Format

stringVar.indexOf(substring [, offset])

Table 43 describes the arguments for the Search String for Substring method.

Table 43. Arguments for the Search String for Substring Method
Argument
Description

substring

One or more characters that this method searchs.The substring argument can contain a single character.

offset

The position in the string where this method starts searching. This method does the following according to how you set the offset argument:

  • You specify the offset argument. Starts searching at the position that you specify in the offset argument.
  • You do not specify the offset argument. Starts searching at position 0.
Example 1

The following example returns the position of the first a character that occurs in the string. In this example, the first a character occurs at position 2:

var string = "what a string";
var firsta = string.indexOf("a")

Example 2

The following example returns 3, which is the position of the first a character in the string when starting from the second character of the string:

var magicWord = "abracadabra";
var secondA = magicWord.indexOf("a", 1);

Related Topics

For more information, see the following topics:

Siebel eScript Language Reference Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.