in reply to Re^2: Elegant way to split into sequences of identical chars?
in thread Elegant way to split into sequences of identical chars?
It looks like a question of greedy star vs. returning the first possible match and if \1 is evaluated before returning the match to me, but I dont feel much confidence to guess any further.use warnings; use strict; use re 'debug'; my $re = qr/(.)\1*/; my @matches; my $string = "xx556xx"; @matches = $string =~ m/($re)/g; print "@matches\n\n"; # x x x x 5 5 5 5 6 6 x x x x @matches = $string =~ m/((??{$re}))/g; print "@matches\n\n"; # xx 55 6 xx
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Elegant way to split into sequences of identical chars?
by xdg (Monsignor) on Nov 30, 2005 at 21:14 UTC | |
Re^4: Elegant way to split into sequences of identical chars?
by Roy Johnson (Monsignor) on Nov 30, 2005 at 18:14 UTC | |
by jonix (Friar) on Nov 30, 2005 at 19:48 UTC |