Hi Jake,
There is some help in this skill do***entation actually. I don't see a
solution for your request though. Let me explain
According to the skill do***ent :
\(=85\): A regular expression wrapped as \( form \) matches whatever
form matches, but saves the string matched in a numbered register
(starting from one, can be up to nine).
\n: A backslash followed by a digit n matches the contents of the nth
register from the current regular expression.
There is an example (From the doc also):
; The target "123 cells" does not begin with a-z/A-Z.
1. rexCompile("\\([a-z]+\\)\\.\\1") =3D> t
2. rexExecute("abc.bc") =3D> t
3. rexExecute("abc.ab") =3D> nil
The compiled regular expression in line 1 would be : "match.match"
the first match will be captured into the memory/register thanks to
the grouping with the parenthesis. This captured match would then be
invoked using the regEx internal variable \1, simple as that. Line 2
evaluates to 't' because the regEx engine manages to find the same
pattern before and after the dot, This pattern was 'bc'.
Try this other example ...
rexCompile("\\([a-z]+\\)\\.\\1.*\\([a-z]+\\)\\.\\2")
rexExecute("ffffoo.foo.totobar.bar")
rexExecute("ffffoo.foo.totobar.camp")
As far as I understand, variables \1, ...\9 are valid in the regular
expression scope only. I don't see any way to print it or assign it to
a regular skill variable as I can do in Perl for example. That's my
personal understanding and I'm might be wrong.
I'm more familiar with regular expressions with Perl. Perl got
variables like $&, $`, $' and $1...9 to print out patterns related to
the matching of regular expressions:
I could run the following Perl command to get the matching from the
1st skill regExp:
PERL> print "$1\n" if $_=3D~m/([a-z]+)\.\1/
That was my understanding so far.
Hope this helps anyway !
Riad.


|