FIELD(), FIELDS() |
![]() ![]() ![]() |
The FIELD() function returns one or more delimited substrings from a string. The FIELDS() function is similar to FIELD() but operates on a multi-valued string, returning a similarly structured dynamic array of results.
Format
FIELD(string, delimiter, occurrence {, count})
where
The FIELD() function extracts count substrings starting at substring occurrence from string. Substrings within string are delimited by the first character of delimiter. If delimiter is a null string, the entire string is returned.
If the value of occurrence is greater than the number of delimited substrings in string, a null string is returned.
If the value of count is greater than the number of delimited substrings in string starting at substring occurrence, the remainder of string is returned. Additional delimiters are not inserted.
The COL1() and COL2() functions can be used to find the character positions of the extracted substring.
Use of the $NOCASE.STRINGS compiler directive makes the delimiter case insensitive.
Example
A = "1*2*3*4*5" S = FIELD(A, '*', 2, 3)
This program fragment assigns the string "2*3*4" to variable S.
See also: |