IndexOfString

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

IndexOfString

The IndexOfString function returns the zero-based index of the first occurrence of the search string in the input string. If the Search string is not found, the function returns -1.

Syntax

int IndexOfString(
  string targetString,
  string searchString,
  bool ignoreCase
);

Parameters

  • targetString
    The string to be searched.

  • searchString
    The string to search for.

  • ignoreCase
    Optional. If set to true, the search will be case-sensitive. If either set to false or not set, the search will be case-insensitive.

Return Values

Returns a zero-based index of the first occurrence of the search string in the input string. If the search string is not found, returns -1. Also, it returns -1 if either targetString or searchString is empty, null or the length of the target string is less than that of the search string.