my @x;
while (/(?=((\d)(\d)))/g) {
push @x, $1 if $3 > $2;
}
You could also do that nicely using a lookup.
my %ok;
for my $i (1..8) {
for my $j ($i+1..9) {
$ok{"$i$j"} = 1;
}
}
my @x = grep $ok{$_}, /(?=(\d\d))/g;
You could build a complex pattern.
use Regexp::List qw( );
my @ok;
for my $i (1..8) {
for my $j ($i+1..9) {
push @ok, "$i$j";
}
}
my $re = Regexp::List->new()->list2re(@ok);
my @x = /(?=($re))/g;
In can be done programmatically in the regexp as well.
my @x;
push @x, $1 while /(?=((\d)(\d)(?(?{ $3 <= $2 })(?!))))/g;
(It's pretty crazy that I was able to write the last one without errors and without checking perlre, so you probably shouldn't use that one.)
All tested.
|