RegExpr provides regular expression matching of text strings.
INTERFACERegExpr ; TYPE T <: REFANY;
The special expression NIL matches every string.
PROCEDURE Compile (pattern: TEXT): T RAISES {Error};
Translate the string pattern and return its internal form. PROCEDURE Match (t: T; txt: TEXT): BOOLEAN;
ReturnsTRUEiftxtmatches the patternt.
PROCEDURE MatchSub (t: T; READONLY str: ARRAY OF CHAR): BOOLEAN;
ReturnsTRUEifstrmatches the patternt.
PROCEDURE MatchSubstring (t: T; txt: TEXT; pre, post: CARDINAL): BOOLEAN;
ReturnsTRUEifamatches the patterntwhen the firstprecharacters and lastpostcharacters are dropped.
PROCEDURE SimpleString (t: T): TEXT;
Returns the string that matches t if it contains no non-trivial
regular expression operators. Otherwise, returns NIL. EXCEPTION Error (TEXT); END RegExpr.The pattern grammar is:
pattern matches
------------- ------------------------------------
<expr1>|<expr2> strings matching <expr1> or <expr2>
<expr1>&<expr2> strings matching <expr1> and <expr2>
(expr) strings matching <expr>
* any string of zero or more characters
@ any single character
\* the single character '*' (asterisk)
\@ the single character '@' (at sign)
\| the single character '|' (vertical bar)
\& the single character '&' (ampersand)
\( the single character '(' (left parenthesis)
\) the single character ')' (right parenthesis)
\\ the single character '\' (back slash)
<char> any other single character not mentioned above.
& has higher precedence than |.