APARSE Function

Parses a string into words and returns the number of words found and places the words in an array.

Category: String
Returned data type: Integer

Syntax

APARSE(string,delimiter,word_list)

Required Arguments

string

a string that represents the string that needs to be separated into words; this can be specified as fixed string, field name, or expression

Restriction: string should not be NULL, it causes a run-time error.
Note: If string is empty (""), a value of 1 is returned and word_list has one element that contains an empty string.

delimiter

a string that contains the character to be used as delimiter when separating the string into words; this can be specified as fixed string, field name, or expression

Restriction: If multiple characters are specified, only the last character is used.

word_list

a string array that represents the words that were found during parsing, this is specified as a field name

returns

an integer that represents the number of words found

Comparisons

The PARSE function is similar. It returns individual string fields instead of a string array, the string fields must be specified as part of the function invocation. The APARSE function does not have this restriction and can therefore be used when the maximum number of words is not known in advance.

Examples

string = "one:two:three"

delimiter = ":"

nwords = aparse(string, delimiter, word_list) // outputs 3

first_word = word_list.get(1) // outputs "one"

last_word = word_list.get(nwords) // outputs "three"