-
Notifications
You must be signed in to change notification settings - Fork 854
Open
Description
New Issue Checklist
- [ x ] Updated PhoneNumberKit to the latest version
- [ x ] Phone number formatted correctly on JavaScript version
- [ x ] I searched for existing GitHub issues
- [ x ] I am aware that this library is not responsible of adding/removing/changing phone number formats and any request should be done at libphonenumber repo
Steps to reproduce
Construct formatter for Argentina and execute it:
let formatter = PartialFormatter(
utility: PhoneNumberUtility(),
defaultRegion: "AR",
withPrefix: false,
maxDigits: nil,
ignoreIntlNumbers: false
)
let result = formatter.formatPartial("+54387615")
Expected result
38-7615
Actual result
``
Environment
Swift Package maneger
Details
Current Regex for Argentina usec in PartialFormatter.extractNationalPrefix is
^(?:0?(?:(11|2(?:2(?:02?|[13]|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:02?|1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[67])|4(?:7[3-578]|9)|6(?:[0136]|2[24-6]|4[6-8]?|5[15-8])|80|9(?:0[1-3]|[19]|2\d|3[1-6]|4[02568]?|5[2-4]|6[2-46]|72?|8[23]?))|3(?:3(?:2[79]|6|8[2578])|4(?:0[0-24-9]|[12]|3[5-8]?|4[24-7]|5[4-68]?|6[02-9]|7[126]|8[2379]?|9[1-36-8])|5(?:1|2[1245]|3[237]?|4[1-46-9]|6[2-4]|7[1-6]|8[2-5]?)|6[24]|7(?:[069]|1[1568]|2[15]|3[145]|4[13]|5[14-8]|7[2-57]|8[126])|8(?:[01]|2[15-7]|3[2578]?|4[13-6]|5[4-8]?|6[1-357-9]|7[36-8]?|8[5-8]?|9[124])))15)?)
The regex matches the entire input "387615" as a national prefix because Argentina's nationalPrefixForParsing pattern is designed to match area codes followed by "15" (the mobile prefix).
Why "387615" matches:
Argentina's national prefix pattern includes area code "3876" (Jujuy province):
3 - start of 3xx area codes
8 - the 8 subgroup
76 - matches 7[36-8]? (7 followed by optional 6)
15 - the mobile prefix
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels