-
Notifications
You must be signed in to change notification settings - Fork 49
Fix French PhoneNumber regexp #117
Fix French PhoneNumber regexp #117
Conversation
@@ -13,7 +13,7 @@ | |||
'national' => [ | |||
'general' => '/^[124-9]\\d{8}|3\\d{3}(?:\\d{5})?$/', | |||
'fixed' => '/^[1-5]\\d{8}$/', | |||
'mobile' => '/^(?:[6-7]\\d{8}|7[5-9]\\d{7})$/', | |||
'mobile' => '/^(?:700\\d{6}|6\\d{8}|7[3-9]\\d{7})$/', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why the regex pattern differs from the Google library? Or did I miss something?
<nationalNumberPattern>
700\d{6}|
(?:
6\d|
7[3-9]
)\d{7}
</nationalNumberPattern>
https://github.com/google/libphonenumber/blob/v8.10.19/resources/PhoneNumberMetadata.xml#L9361-L9367
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@froschdesign The result is the same:
- in google library we have:
a|((b|c)d)
- in PR we have
a|e|f
, wheree = bd
andf = cd
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is this same result, but why not copy the pattern from the reference?
I want to go one step further: we need an update script for all regex patterns because there are more old and outdated patterns in this library. This means, it would result in copying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use it as the reliable source for all patterns? If so we can write a simple script to update patters, because right now I am super confused with so many regexp... For example I've also noted that we have more rules/countries in the library than it is in the google (we do have XK - Kosovo, and it is not present there).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we simplify the process and use an external library: libphonenumber for PHP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@froschdesign I guess, it will be for v3 - where we can change the approach completely, use the external library or use reliable source for all patterns.
Fix French PhoneNumber regexp
Fixes #85