in reply to Regex question
use strict; use warnings; my @dotted_stuff = ( q(), '1.A', '12.1', '1.9', '01.9', '1.9.1', '1.9.2.1', '12.1.1', '12.13', ); for my $va (@dotted_stuff) { for my $vb (@dotted_stuff) { printf qq(%-7s and %-7s => ), $va, $vb; if ($va =~ m{ \A (\d+) \. (\d+) }xms) { my ($a1, $a2) = ($1, $2); if ($vb =~ m{ \A (\d+) \. (\d+) }xms) { my ($b1, $b2) = ($1, $2); if ($a1 == $b1 and $a2 == $b2) { print "MATCH!\n"; next; } } } print "no match.\n"; } }
|
|---|