my @strings = qw(
aaaaa
eeeee
iiiii
abcde
aeiou
bdfhj
);
my %regexes = (
alternation => qr/a|A|e|E|i|I|o|O|u|U/,
class => qr/[AaEeIiOoUu]/
);
foreach my $string (@strings)
{
print "$string:\n";
while (my ($k, $r) = each %regexes)
{
print "\t$k - " . ($string =~ /$r/ ? 'YES' : 'NO') . $/;
}
}
---------------
aaaaa:
alternation - YES
class - YES
eeeee:
alternation - YES
class - YES
iiiii:
alternation - YES
class - YES
abcde:
alternation - YES
class - YES
aeiou:
alternation - YES
class - YES
bdfhj:
alternation - NO
class - NO
Please give me a counter-case. As far as I can tell, the two regexes are identical, save that the alternation one is slower.
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
|