Module phonenumber
source code
Code for normalising and formatting phone numbers
This doesn't (yet) try to deal with international numbers. The rule is
that if the string contains 10 digits (with an optional preceding one)
then it is reduced to the 10 digits (all non-digit characters removed,
optional leading one removed).
If the string doesn't meet those criteria then it is passed through as
is.
For formatting, 10 digit strings are formatted in standard US
notation. All others are left as is.
|
_notdigits = re.compile(r'[ ^ 0- 9] * ')
|
|
_tendigits = re.compile(r'^[ 0- 9] {10} $')
|
|
_sevendigits = re.compile(r'^[ 0- 9] {7} $')
|