in reply to Re: Recursive regular expression weirdness
in thread Recursive regular expression weirdness
The (?{ [] }) at the start of $rxOnlyNested creates an empty list reference and the reference will be held in $^R (the result of the last code block). In $rxNest the (?{ [ @{$^R}, $1 ] }) at the end creates a new list reference which contains the dereferenced contents of the last list plus the memory group of the successful match. This list keeps growing as the regular expression recursed, in effect. Finally, in $rxOnlyNested the list is dereferenced and assigned to @memoList.
I hope I have understood correctly and if it is doing what I think it is doing, it is a very neat solution. I am glad I have finally started visiting the Monastery as I am learning a lot of new techniques.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Recursive regular expression weirdness
by ikegami (Patriarch) on Mar 30, 2006 at 15:41 UTC | |
by johngg (Canon) on Mar 30, 2006 at 18:45 UTC | |
by ikegami (Patriarch) on Mar 30, 2006 at 19:05 UTC | |
by johngg (Canon) on Mar 30, 2006 at 20:19 UTC |