Pre-compiling only:
xcall REGEX, pattern, patno
General use:
xcall REGEX, pattern, status, subject {, flags, stpos, match1, & subcnt, ... matchn}
REGEX.SBR is A-Shell's regular expression processor. See Background and General Information for an in-depth discussion of regular expressions. Also see the following subsections of this document:
Parameters
pattern (string) in
Regular expression (without the Perl-style leading/trailing slash). To specify a pre-compiled pattern, set PATTERN = chr$(1) thru chr$(20) (for the 20 precompiled patterns).
status (f or i)
Value |
Returned status values |
---|---|
>0 |
Matching success (# of matches) |
-99 |
Too few parameters |
-98 |
Unable to load PCRE library (PCRE3.DLL under Windows) |
-97 |
Unable to allocate memory for library |
-96 |
Unable to link to pcre_compil2 or pcre_exit function in lib |
-95 |
Invalid pre-compiled pattern number (1-20) |
-94 |
No such precompiled pattern (not previously compiled) |
patno (f or i) in/out
For precompiling, on input must be set to an integer 1-20 (for the 20 numbered precompiled patterns). On output, will still be set to the same value for success, or <=0 on error (see STATUS codes below).
subject (string) in
Subject string to test against the pattern
flags (f or b4) in
for compiling, defined in achinc:regex.def. See Options Flags below.
stpos (num) in
Optional starting position in SUBJECT, base 1. If not specified or zero, treated same as 1 (i.e. start at beginning of SUBJECT).
match1 (string) out
Returns the string within the SUBJECT that was matched. On errors, it may returns the text of the error description.
subcnt (num) out
Returns # of subexpression matches. This is an advanced feature of regular expressions; see MATCHn params and refer to the literature on the web for more information.
matchn (string) out
These return subexpression matches (up to the number specified by SUBCNT). Note that currently there is an internal limit of 20 subexpression matches. If you pattern is more complex than that, it will likely fail.