indexOf()

The strLib.indexOf() system function returns an index into a string of characters; the index indicates where a specified pattern begins.

Syntax

  strLib.indexOf(
    source STRING | UNICODE | CHAR | DBCHAR | MBCHAR inOut,
    pattern STRING | UNICODE | CHAR | DBCHAR | MBCHAR in
    [, startPosition INT in] )
  returns (result INT)
source
Input can be any value that is assignment compatible with the types shown.
pattern
A sequence of characters that EGL searches for in source. The value must be the same type as source.
startPosition
The number of initial characters in source to ignore before beginning the search for pattern. If this value is not valid (less than 0 or greater than the length of source), the function throws an IndexOutOfBounds exception.
result
The index of the beginning of pattern within source. If pattern is not found, the function returns 0.

Example

  source STRING = "STRING; CHAR; DBCHAR; MBCHAR; or UNICODE.";
  pattern STRING = "; "
  
  result = strLib.indexOf(source, pattern);
  // result is 7
  result = strLib.indexOf(source, pattern, 10);
  // result is 13

Feedback