util.Regexp.split

Splits a string around matches of the current regular expression.

Syntax

util.Regexp.split(
  subject STRING
 )
  RETURNS DYNAMIX ARRAY OF STRING
  1. subject is the string to be scanned.

Usage

This method scans the string passed as first parameter and generates a dynamic array with all tokens terminated by separators matching the current compiled regular expression.

The tokens can be terminated by the substring that matches the regular expression, or is terminated by the end of the string.

If the expression does not match any part of the input, then the resulting array has just one element, which is a copy of this string.

Example

IMPORT util
MAIN
    DEFINE re util.Regexp
    DEFINE tokens DYNAMIC ARRAY OF STRING
    DEFINE x INTEGER
    LET re = util.Regexp.compile(`[ ;:]`)
    LET tokens = re.split("aa bb;cc:dd")
    FOR x=1 TO tokens.getLength()
        DISPLAY tokens[x]
    END FOR
END MAIN
Output:
aa
bb
cc
dd