Caché MultiValue Basic Reference
INDEX
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Class Reference   
Search:    

Returns starting position of a substring in a string.
Synopsis
INDEX(string,substring,occurs)
Arguments
string The string to be searched for substring. An expression that resolves to a string or a numeric value.
substring An expression that resolves to a substring to locate within string.
occurs An expression that resolves to a positive integer specifying which occurrence of substring to locate.
Description
The INDEX function returns the starting character position, counting from 1, of substring within string. Matching of substring is case-sensitive. You use the occurs argument to specify which occurrence of substring to return the location of.
INDEX returns 0 for any of the following:
If substring is the null string (""), INDEX returns 1. If both string and substring are the null string (""), INDEX returns 1.
If occurs is a mixed numeric string, the numeric part is parsed until a non-numeric character is encountered. Thus “7dwarves” is parsed as 7.
See Also