i = pos(substring, source_string);
The
pos function searches for a grouping of characters, represented in a
substring, within a
source_string. The function returns the beginning position of the first occurrence of the substring. Both arguments are string expressions, and they are case sensitive, meaning that
"children" is recognized as different from
"CHILDREN".
If using an
alpha string or dictionary item, be aware that searching for a space character can lead to the function finding one at the end of your string. You may want to
strip alphanumeric variables before searching for spaces.
The function returns the position of the first occurrence of the substring, or if the substring is not found, the function returns 0.
VALUE = pos("L", "FOR THE CHILDREN"); // VALUE will be 12; this is where the
// substring (the letter "L") occurs in the
// source string ("FOR THE CHILDREN")
VALUE = pos("DRE", "CHILDREN"); // VALUE will be 5; this is where the
// substring ("DRE") occurs in the source string
VALUE = pos("DCN", "CHILDREN"); // VALUE will be 0; the substring ("DCN") does
// not occur in the source string