Utility Functions : Calling Utility Functions : Location of Pattern in a String

Location of Pattern in a String

The index function returns the first location from the left (starting with 0), in which pattern appears in the input string. It returns -1 when the pattern is not found.

The syntax is as follows:

stm_index (string, offset, pattern, status)

In this syntax:

stm_—The standard prefix of Statemate functions.
index—Signifies that the function looks for a location in the string.
string—The input string in which the pattern is searched.
offset—An integer greater than or equal to zero that represents the location at which the search begins.
pattern—The string to search for.
status—The return status code. The possible values are stm_success or stm_null_string (when uninitialized strings are used as parameters).

For example:

stm_index(’ABCA’,0,’C’,status) = 2
stm_index(’ABCA’,0,’AB’,status) = 0
stm_index(’ABCA’,2,’A’,status) = 3
stm_index(’ABCA’,0,’AC’,status) = -1