Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

doesn't parse numbers with extensions? #13

Open
ericcj opened this issue Nov 1, 2013 · 6 comments
Open

doesn't parse numbers with extensions? #13

ericcj opened this issue Nov 1, 2013 · 6 comments

Comments

@ericcj
Copy link

ericcj commented Nov 1, 2013

2.0.0-p247 :013 > GlobalPhone.parse('(201) 482-4764x1234')
=> nil
2.0.0-p247 :014 > GlobalPhone.parse('+12014824764x1234')
=> nil
2.0.0-p247 :015 > GlobalPhone.parse('+12014824764 ext. 1234')
=> nil

@trliner
Copy link

trliner commented Dec 16, 2013

This would be a nice feature.

@hoguej
Copy link

hoguej commented Sep 11, 2014

truth

@eileencodes
Copy link
Collaborator

I know this was a long time ago, but I'm not sure what feature you're requesting. You want numbers with extensions to be parsed? Or you think that parsing them should return an error and not nil? If you're still interested in this feature can you clarify it and I'll reopen this issue. Thanks!

@trliner
Copy link

trliner commented Oct 5, 2015

I think the requested feature was to start parsing numbers with extensions. Right now, I'm using a regex to grab the part of the number in front of the extension before parsing it, but it would be nice if global_phone did that internally.

# In order to allow for extensions, we have to split on the first character that's not  
# a digit, white space character, parenthesis, period, plus sign, or minus sign, then 
# parse the first part.
phone_string = '(201) 482-4764x1234'
number_part = phone_string.split(/[^\d\s\(\)\.\-\+]/).first
parsed_number = GlobalPhone.parse(number_part)

@eileencodes
Copy link
Collaborator

Thanks @trliner, I better understand the issue now. If anyone is interested in a PR that would be great. I'm not sure when I'll get around to implementing this, but I'll reopen.

@theblang
Copy link

theblang commented Sep 6, 2016

Strike this, just realized this is a re-implementation and not a wrapper.

Out of curiosity, why is this a problem with GlobalPhone? Shouldn't GlobalPhone be passing off to libphonenumber, which does support using extensions? I have run into the same issue, where GlobalPhone doesn't parse the number when an extension is present.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants