... I've been experimenting again with using Perl regexes more like grammars ...
My kneejerk reaction (and, I suspect, that of many others) on reading something like this is, "Why not just use a grammar?" At least in Perl 5, regexes can be quite useful when applied to limited grammar parsing tasks, but will quickly run out of steam and fall over (or else become monstrously unwieldy) when pushed beyond a certain limit. I suspect the situation may be different with Perl 6, but I must confess ignorance here. In any event, my impression is that the Perl 6 regex compiler/engine is so radically different from that of Perl 5 that feature back-ports can only be piecemeal and incremental.
Further, It's easy to come up with limited approaches to deal with oddball problems, e.g., dynamically varying quantifier counts:
Something like this can take care of an immediate problem, but obviously isn't going to integrate well into an even moderately large parser application — and then we're back to the "get a real parser" stance.c:\@Work\Perl>perl -wMstrict -MData::Dump -le "my $s = '04abcdefgh06ABCDEFGH05tuvwxyz'; my @caps = map join('', m{ \A (\d\d) }xms, m{ ([[:alpha:]]{$1}) }xms), $s =~ m{ \G \d\d [[:alpha:]]+ }xmsg ; dd @caps; " ("04abcd", "06ABCDEF", "05tuvwx")
Please don't take these remarks as an attack on your interest in the problem. I share and applaud that interest and will upvote the OP as soon as I finish posting this. I love regexes too, but we must learn to recognize the limitations even of those we love most.
Give a man a fish: <%-(-(-(-<
In reply to Re: Advanced techniques with regex quantifiers
by AnomalousMonk
in thread Advanced techniques with regex quantifiers
by smls
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |