util.Regexp.getMatchAll

Returns an array with all matches of the regular expression in the subject.

Syntax

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

Usage

The getMatchAll() method returns all occurrences of the strings matching the regular expression, in the string passed as parameter.

The method returns an empty array, if the passed string does not contain any matching string for the current regular expression.

Example

IMPORT util
MAIN
    DEFINE re util.Regexp
    DEFINE arr DYNAMIC ARRAY OF STRING
    LET re = util.Regexp.compile(`[ABC]XX`)
    LET arr = re.getMatchAll("ZBXXZAXXZCXX")
    DISPLAY arr[1]
    DISPLAY arr[2]
    DISPLAY arr[3]
END MAIN
Output:
BXX
AXX
CXX