http://www.perlmonks.org?node_id=1027919


in reply to Re^2: Regex Modification
in thread Regex Modification

How about
use strict; use warnings; my @nums =( '123-456-789', '123.789.456', '963 456 741', '123-456.789', '123 789-456', '963.456 741', '123456789', '123-456' ); for my $num (@nums) { print "$num "; $num =~ s/[0-9]//g; if ($num =~ m/^([-. ])\1*$|^$/) { print "matches \n"; } else { print "does not match \n"; } }
If the last number should not match, just delete the * in the regex