include "regex.m"; regex:= load Regex "/dis/regex.dis"; compile: fn(e: string) : Re; execute: fn(x: Re; s: string): (int,int);
The execute function matches the compiled regular expression x against string s. It returns indexes of the first character of the longest leftmost match and of the next character beyond the match, or (-1,-1) if no match exists.
The primitives in regular expressions are:
Repetitions are built from primitives, p, in the following ways.
p
|
one match to p
|
p?
|
zero or one matches to p
|
p*
|
zero or more matches to p
|
p+
|
one or more matches to p
|
r
|
a repetition
|
re1
|
concatenation: a match to r followed by a match to e1
|
e1|e2
|
alternation: a match to either e1 or e2; concatenation takes precedence over alternation
|
regex:Regex; (beg, end):= regex->execute(regex->compile("[ABCb-z]+"), s:="aAbBcCdD"); #s[beg:end] == "AbBcCd" (beg, end):= regex->execute(regex->compile("a*b*"), "bbaabb"); #(beg, end) == (0,2) re:= regex->compile("(thick)* (chocolate|raspberry)?(topp|fill)ing");
infernosupport@lucent.com Copyright © 1996,Lucent Technologies, Inc. All rights reserved.