$INDEX locates the left‑most position in an alphanumeric expression where a search string can be found. $INDEX returns 0 if the search string is not found in the expression. It returns a value of NULL if the expression or the search string evaluates to NULL.
This function has the following format:
$INDEX (alphanumeric‑expression,SEARCH=substring)
Defines the string to scan for the first occurrence of the substring.
Specifies the alphanumeric identifier, literal, or alpha‑group that is the substring to find. This expression must be surrounded by delimiters if it is an alphanumeric literal. It can be a nullable field.
This function is especially useful for extracting a substring with the $SUBSTR function, as shown in the following example.
Example
Assume that A is a 17‑character alphanumeric expression, B is a five‑character alphanumeric expression, and I is a numeric field.
SET A = 'THESE THREE WORDS'
SET I = $INDEX (A,SEARCH='THREE') :result is 7 SET B = $SUBSTR (A,START=I,LENGTH=5) :result is 'THREE' SET B = $INDEX (A, SEARCH= 'TTT') : result is 0
|
Copyright © 2015 CA Technologies.
All rights reserved.
|
|