Comments (4)
That's interesting. For this example it returns only last matched number, however it can parse both numbers well
text = "Call me at (067) 97-28-961 r on 097922458 after 10am."
for match in phonenumbers.PhoneNumberMatcher(text, "UA"):
print(match)
Returns: 097922458
text = "Call me at (067) 97-28-961 after 10am."
for match in phonenumbers.PhoneNumberMatcher(text, "UA"):
print(match)
Returns: (067) 97-28-961
from python-phonenumbers.
For your first example you need to change the leniency of the matcher; the first number is possible but not valid as a Russian number, and the second number is neither possible nor valid:
>>> text = "Call me at (067) 97-28-961 r on 097922458 after 10am."
>>> x = phonenumbers.parse("0679728961", "RU")
>>> phonenumbers.is_valid_number(x)
False
>>> phonenumbers.is_possible_number(x)
True
>>> y = phonenumbers.parse("097922458", "RU")
>>> phonenumbers.is_valid_number(y)
False
>>> phonenumbers.is_possible_number(y)
False
>>> for match in phonenumbers.PhoneNumberMatcher(text, "RU", leniency=phonenumbers.Leniency.POSSIBLE):
... print(match)
...
PhoneNumberMatch [11,26) (067) 97-28-961
For your second example, as Ukrainian numbers the first number is valid and the second number is possible-but-not-valid:
>>> text = "Call me at (067) 97-28-961 r on 097922458 after 10am."
>>> text2 = "Call me at (067) 97-28-961 after 10am."
>>> x = phonenumbers.parse("0679728961", "UA")
>>> phonenumbers.is_valid_number(x)
True
>>> y = phonenumbers.parse("097922458", "UA")
>>> phonenumbers.is_valid_number(y)
False
>>> phonenumbers.is_possible_number(y)
True
>>> for match in phonenumbers.PhoneNumberMatcher(text, "UA"):
... print(match)
...
PhoneNumberMatch [11,26) (067) 97-28-961
>>> for match in phonenumbers.PhoneNumberMatcher(text2, "UA"):
... print(match)
...
PhoneNumberMatch [11,26) (067) 97-28-961
>>> for match in phonenumbers.PhoneNumberMatcher(text, "UA", leniency=phonenumbers.Leniency.POSSIBLE):
... print(match)
...
PhoneNumberMatch [11,26) (067) 97-28-961
PhoneNumberMatch [33,42) 097922458
>>> for match in phonenumbers.PhoneNumberMatcher(text2, "UA", leniency=phonenumbers.Leniency.POSSIBLE):
... print(match)
...
PhoneNumberMatch [11,26) (067) 97-28-961
from python-phonenumbers.
020 7851 7813 Doesn't work for me!
for match in phonenumbers.PhoneNumberMatcher(text, "gb", phonenumbers.Leniency.POSSIBLE):
n = phonenumbers.format_number(match.number, phonenumbers.PhoneNumberFormat.INTERNATIONAL)
print(n)
from python-phonenumbers.
@kiranshub , this issue was closed over two and half years ago -- please could you raise a separate issue with more details of what isn't working for you (including library version etc.).
from python-phonenumbers.
Related Issues (20)
- Validate a phone number string against E164 standard HOT 1
- region_code_for_number returning None for Some Valid US numbers. HOT 1
- brazil number encountered as invalid even though the client claims it is HOT 1
- Support for ISO3166-1 country codes HOT 2
- United States area code 557 is not working in python-phonenumbers HOT 5
- Dutch public services numbers: eg. 140418 HOT 2
- Automatically track upstream version HOT 7
- Bus factor of 1 HOT 6
- Error parsing phone numbers with double leading 1's HOT 3
- Issue with Kuwait number HOT 1
- is_valid_number broken in latest version (8.13.19) HOT 1
- Embracing Cython 3.0 pure python mode to speed-up the library HOT 2
- 8.13.23: pytest cannot find any units HOT 1
- IE164 contains trailing zero (should be removed) HOT 3
- Carrier names for US numbers returning null HOT 1
- Inconsistent parsing for Gabon phone numbers HOT 1
- Region FR national_number_pattern requires an update HOT 2
- country_code: 353 phone: ks.123456789 is getting parsed without any invalid error. is this expected? HOT 1
- Validation issues for some Australian numbers HOT 3
- PhoneInfoga
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-phonenumbers.