Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Numbers only in a string

by superfrink (Curate)
on Sep 09, 2005 at 05:02 UTC ( [id://490429]=note: print w/replies, xml ) Need Help??


in reply to Re: Numbers only in a string
in thread Numbers only in a string

I added one line to get up to 10 digits starting from the right side. This will remove the leading "1" and I think any country code. (I'm assuming the phone number is in the format for Canada/USA.)
while(<DATA>) { s/[^\d]+//g; # remove non-digit characters # only digit characters remain m/(.{0,10})$/; # find as many as 10 characters, # starting at the right print $1,$/; # print the found digits } __DATA__ 800-1212 1-800-800-1212 1(800)800-1212 1 (800) 800-1212 1 800 800 1212

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-25 04:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found