STRING.split

Splits the current string around matches of the given regular expression.

Syntax

split(
     regex STRING )
   RETURNS DYNAMIC ARRAY OF STRING
  1. regex is the regular expression defining token separators. See Regular expression patterns.

Usage

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

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.

Note: When using single or double quoted string literals, backslash is interpreted as escape character. Consider using back quotes as delimiters for regular expressions strings, and use backslash characters directly as required by the regexp syntax ( `\b` instead of "\\b" or '\\b' )

Example

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