Closed ericfong closed 7 years ago
Oh, just saw your issue. :)
Could you provide a concrete example of a phone string that should be matched but is not?
Thanks !
My app should parse phone number from HK. Which should be
valid: [
'91234567',
'9123-4567',
'61234567',
'51234567',
'+85291234567',
'+852-91234567',
'+852-9123-4567',
'852-91234567',
],
invalid: [
'999',
'+852-912345678',
'123456789',
'+852-1234-56789',
],
Regex for mobile phone numbers (not yet include landline) for different locales https://github.com/chriso/validator.js/blob/master/src/lib/isMobilePhone.js
Test cases for those numbers https://github.com/chriso/validator.js/blob/master/test/validators.js#L2129-L2806
I think that is out of scope for this lib to make the phone number regex prefect. But let user to plugin there own logic will be really great. Thanks a lot
Thanks for the clarification !
@ericfong How do you solve the last ?
I used regex and parse string by my little util
Reger to https://github.com/gregjacobs/Autolinker.js/blob/4ab2ca8005cc1fcbd8c914f4a7e9a0718503366f/src/matcher/Phone.js#L44
with Regex test against match[2] and /\D/.test(matchedText)
basically disallow people use another matcherRegex or change
Autolinker.matcher.Phone.prototype.matcherRegex = /(+)?(\d{3,5}[- .]?)+\d{3,5}/g We replaced the matcherRegex to match phone number in our country, but our regex won't contain a match[2] that match /\D/
I know that maybe internal API. But please provide other customisable point. Thanks for your package