Please enable JavaScript to view this site.

A-Shell Development History

REGEX.SBR enhancement: You can now use an array, even an array of dynamic elements, in place of the individual sub-match parameters. To do so, you must first set SUBCNT to the maximum number of elements in the array, and in addition, set the new PCREX_SUBMATCH_ARRAY (defined as &h40000000 in REGEX.DEF) in the FLAGS parameter. For example:

MAP1 SUBMATCH(20),S,0

...

SUBCNT = .EXTENT(SUBMATCH())           ! (i.e. SUBCNT = 20)

FLAGS = FLAGS or PCREX_SUBMATCH_ARRAY

XCALL REGEX,PATTERN,STATUS,SUBJECT,FLAGS,STPOS,MATCH,SUBCNT,SUBMATCH(1)

 

On return, SUBCNT will be set to the total number of sub-matches, and the elements of the array SUBMATCH() will be assigned accordingly (up to the number of elements passed in to REGEX in the SUBCNT parameter). Note that the array may contain empty elements, as not all possible sub-matches (aka "capture groups") will match up to the subject string.

Also, the maximum number of allowed sub-matches has been increased from 20 to 100.

Note that when a capture group is effectively matched multiple times, only the last match for each capture group is returned. Thus the usefulness of submatches (particularly where REGEX is used as an aid to parsing) is mainly limited to simple capture groups that are to be matched zero or one time.