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