Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Regex Modification

by si_lence (Deacon)
on Apr 10, 2013 at 07:54 UTC ( #1027919=note: print w/ replies, xml ) Need Help??


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


Comment on Re^3: Regex Modification
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1027919]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2015-08-01 00:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (285 votes), past polls