http://qs321.pair.com?node_id=298407


in reply to multiple matches with regexp

Well, the Perl way is obviously TIMTOWDI, but I have a Perl-ish RegEx way for you ;-):
$a="aaaa"; $a=~m/(aa)(?{push @a, $1})(?!)/; print join ( "-", @a );
This uses (?{}) (just a bit of code within a RegEx that is executed whenever the RE engine runs over it) and (?!) (negative look-ahead), so that it always fails (that's a bit of its magic), both explained in perlre. You could say it is ugly, but I personally like it :-).
Hope this helped.
CombatSquirrel.
Entropy is the tendency of everything going to hell.