GROUP Function
Returns a group of character-delimited fields from within a string.
Syntax
GROUP(string, delimiter, startField, noOfFields)
Syntax Elements
string An expression that evaluates to the string to be searched.
delimiter The character used as a field delimiter. If delimiter contains more than one character, only the first is used.
startField The number of the first field to return. The fields are numbered starting from 1. If the field number is less than 1, field 1 is assumed.
Note that this is different to option G of the OCONV function, in which the fields are numbered starting from 0.
noOfFields The maximum number of fields to return. If noOfFields is greater than the number of fields in the string, GROUP returns all fields from the specified starting field to the end of the string.
Comments
The fields are returned separated by delimiter.
The GROUP intrinsic function is similar to the group extract conversion (option G of the OCONV function), except that fields number from 1 and it allows any delimiter to be specified as the field separator, including system delimiters.
Case Insensitivity
If data case insensitive mode is selected (see Case Sensitivity), case is ignored when searching string for delimiter.
See Also
FIELD function, GROUPSTORE statement.
Examples
CITY = "IRVINE/ORANGE/TUSTIN" Y = GROUP(CITY,"/",3,2)
Returns the value TUSTIN, because it is the third field in string CITY (startField = 3). Only one element is returned because this is the last field in the string.
A = "123":@AM:"456":@AM:"789":@AM:"123" X = GROUP(A,@AM,1,2)
Returns the value 123^456, because they are the first two fields in string A.
B = "A/B/C/D/E" Y = GROUP(B,"/",3,2)
Returns two fields, starting with the third field. Y now has the value C/D.