From c110f58523d3baa4d560fe3bf5121177b4910d99 Mon Sep 17 00:00:00 2001 From: VincentXue Date: Thu, 10 Jan 2019 20:08:06 +0800 Subject: [PATCH] Optimize the compatibility of some regular expressions in JavaScript. --- README-CN.md | 27 ++++++++++++++------------- README.md | 27 ++++++++++++++------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/README-CN.md b/README-CN.md index d7cb324..d5084ab 100644 --- a/README-CN.md +++ b/README-CN.md @@ -2,27 +2,27 @@ 一组匹配中国大陆手机号码的正则表达式。 -## 正则表达式 ([PCRE]) +## 正则表达式 ### 匹配所有号码(手机卡 + 数据卡 + 上网卡) -[`^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7[^29\D](?(?<=4)(?:0\d|1[0-2]|9\d)|\d{2})|9[189]\d{2}|6[567]\d{2}|4(?:[14]0\d{3}|[68]\d{4}|[579]\d{2}))\d{6}$`][匹配所有号码(手机卡 + 数据卡 + 上网卡)] +[`^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7(?:[01356789]\d{2}|4(?:0\d|1[0-2]|9\d))|9[189]\d{2}|6[567]\d{2}|4(?:[14]0\d{3}|[68]\d{4}|[579]\d{2}))\d{6}$`][匹配所有号码(手机卡 + 数据卡 + 上网卡)] ### 匹配所有支持短信功能的号码(手机卡 + 上网卡) -[`^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7[^29\D](?(?<=4)(?:0\d|1[0-2]|9\d)|\d{2})|9[189]\d{2}|6[567]\d{2}|4[579]\d{2})\d{6}$`][匹配所有支持短信功能的号码(手机卡 + 上网卡)] +[`^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7(?:[01356789]\d{2}|4(?:0\d|1[0-2]|9\d))|9[189]\d{2}|6[567]\d{2}|4[579]\d{2})\d{6}$`][匹配所有支持短信功能的号码(手机卡 + 上网卡)] ### 手机卡 #### 匹配所有 -[`^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7[^0129\D](?(?<=4)(?:0\d|1[0-2]|9\d)|\d{2})|9[189]\d{2}|66\d{2})\d{6}$`][匹配基础运营商] +[`^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7(?:[35678]\d{2}|4(?:0\d|1[0-2]|9\d))|9[189]\d{2}|66\d{2})\d{6}$`][匹配基础运营商] #### 匹配中国移动 -[`^(?:\+?86)?1(?:3[^0-3\D](?(?<=4)[^9\D]|\d)|5[^3-6\D]\d|8[23478]\d|(?:78|98)\d)\d{7}$`][匹配基础运营商中国移动] +[`^(?:\+?86)?1(?:3(?:4[^9\D]|[5-9]\d)|5[^3-6\D]\d|8[23478]\d|(?:78|98)\d)\d{7}$`][匹配基础运营商中国移动] #### 匹配中国联通 [`^(?:\+?86)?1(?:3[0-2]|[578][56]|66)\d{8}$`][匹配基础运营商中国联通] #### 匹配中国电信 -[`^(?:\+?86)?1(?:3[34](?(?<=4)(?:9)|\d)\d|53\d{2}|8[019]\d{2}|7[347](?(?<=4)(?:0[0-5])|\d{2})|9[19]\d{2})\d{6}$`][匹配基础运营商中国电信] +[`^(?:\+?86)?1(?:3(?:3\d|49)\d|53\d{2}|8[019]\d{2}|7(?:[37]\d{2}|40[0-5])|9[19]\d{2})\d{6}$`][匹配基础运营商中国电信] #### 匹配北京船舶通信导航有限公司(海事卫星通信) [`^(?:\+?86)?1749\d{7}$`][匹配北京船舶通信导航有限公司(海事卫星通信)] @@ -136,6 +136,9 @@ https://www.debuggex.com (PCRE 在线视觉化) ## 更新日志 +#### 2019.01.10 +- 优化部分正则表达式在 JavaScript 中的兼容性。 + #### 2019.01.07 - 添加 165 号段支持。 @@ -171,19 +174,17 @@ https://www.debuggex.com (PCRE 在线视觉化) MIT -[PCRE]: https://en.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions - -[匹配所有号码(手机卡 + 数据卡 + 上网卡)]: https://www.debuggex.com/r/tLZQT3k0DZqmnP8o +[匹配所有号码(手机卡 + 数据卡 + 上网卡)]: https://www.debuggex.com/r/6Umw2aVUvd0_1eLm -[匹配所有支持短信功能的号码(手机卡 + 上网卡)]: https://www.debuggex.com/r/VbgdCcGSZcr9Kcgi +[匹配所有支持短信功能的号码(手机卡 + 上网卡)]: https://www.debuggex.com/r/cqDse9Gs59bM0YkN -[匹配基础运营商]: https://www.debuggex.com/r/YbIeQ_M4s88_9NHG +[匹配基础运营商]: https://www.debuggex.com/r/uQa_IeV9QnXtOpGI -[匹配基础运营商中国移动]: https://www.debuggex.com/r/_oGTPFpiqUNdaP8t +[匹配基础运营商中国移动]: https://www.debuggex.com/r/dbF9BmNrGrq4vvWi [匹配基础运营商中国联通]: https://www.debuggex.com/r/n8onnyBbDV-hN7mU -[匹配基础运营商中国电信]: https://www.debuggex.com/r/r3m8n91BeWXfncGO +[匹配基础运营商中国电信]: https://www.debuggex.com/r/JBBaP5VO_yD7uDfU [匹配北京船舶通信导航有限公司(海事卫星通信)]: https://www.debuggex.com/r/Ewdta8YJfreoXguf diff --git a/README.md b/README.md index 0b9faf5..726532c 100644 --- a/README.md +++ b/README.md @@ -4,27 +4,27 @@ A set of regular expressions to match the mobile phone number in mainland China. -## Regular Expressions ([PCRE]) +## Regular Expressions ### Match all numbers (Phone number + IoT number + Data only number) -[`^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7[^29\D](?(?<=4)(?:0\d|1[0-2]|9\d)|\d{2})|9[189]\d{2}|6[567]\d{2}|4(?:[14]0\d{3}|[68]\d{4}|[579]\d{2}))\d{6}$`][Match all numbers (Phone number + IoT number + Data only number)] +[`^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7(?:[01356789]\d{2}|4(?:0\d|1[0-2]|9\d))|9[189]\d{2}|6[567]\d{2}|4(?:[14]0\d{3}|[68]\d{4}|[579]\d{2}))\d{6}$`][Match all numbers (Phone number + IoT number + Data only number)] ### Match all numbers with SMS (Phone number + Data only number) -[`^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7[^29\D](?(?<=4)(?:0\d|1[0-2]|9\d)|\d{2})|9[189]\d{2}|6[567]\d{2}|4[579]\d{2})\d{6}$`][Match all numbers with SMS (Phone number + Data only number)] +[`^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7(?:[01356789]\d{2}|4(?:0\d|1[0-2]|9\d))|9[189]\d{2}|6[567]\d{2}|4[579]\d{2})\d{6}$`][Match all numbers with SMS (Phone number + Data only number)] ### Mobile phone number #### Match all -[`^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7[^0129\D](?(?<=4)(?:0\d|1[0-2]|9\d)|\d{2})|9[189]\d{2}|66\d{2})\d{6}$`][Match Carrier] +[`^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7(?:[35678]\d{2}|4(?:0\d|1[0-2]|9\d))|9[189]\d{2}|66\d{2})\d{6}$`][Match Carrier] #### Match China Mobile -[`^(?:\+?86)?1(?:3[^0-3\D](?(?<=4)[^9\D]|\d)|5[^3-6\D]\d|8[23478]\d|(?:78|98)\d)\d{7}$`][Match Carrier China Mobile] +[`^(?:\+?86)?1(?:3(?:4[^9\D]|[5-9]\d)|5[^3-6\D]\d|8[23478]\d|(?:78|98)\d)\d{7}$`][Match Carrier China Mobile] #### Match China Unicom [`^(?:\+?86)?1(?:3[0-2]|[578][56]|66)\d{8}$`][Match Carrier China Unicom] #### Match China Telecom -[`^(?:\+?86)?1(?:3[34](?(?<=4)(?:9)|\d)\d|53\d{2}|8[019]\d{2}|7[347](?(?<=4)(?:0[0-5])|\d{2})|9[19]\d{2})\d{6}$`][Match Carrier China Telecom] +[`^(?:\+?86)?1(?:3(?:3\d|49)\d|53\d{2}|8[019]\d{2}|7(?:[37]\d{2}|40[0-5])|9[19]\d{2})\d{6}$`][Match Carrier China Telecom] #### Match Inmarsat (Satellite Communications) [`^(?:\+?86)?1749\d{7}$`][Match Inmarsat (Satellite Communications)] @@ -140,6 +140,9 @@ https://www.debuggex.com (PCRE visualizer) ## Release Notes +#### 2019.01.10 +- Optimize the compatibility of some regular expressions in JavaScript. + #### 2019.01.07 - Add support for 165 prefix. @@ -175,19 +178,17 @@ https://www.debuggex.com (PCRE visualizer) MIT -[PCRE]: https://en.wikipedia.org/wiki/Perl_Compatible_Regular_Expressions - -[Match all numbers (Phone number + IoT number + Data only number)]: https://www.debuggex.com/r/tLZQT3k0DZqmnP8o +[Match all numbers (Phone number + IoT number + Data only number)]: https://www.debuggex.com/r/6Umw2aVUvd0_1eLm -[Match all numbers with SMS (Phone number + Data only number)]: https://www.debuggex.com/r/VbgdCcGSZcr9Kcgi +[Match all numbers with SMS (Phone number + Data only number)]: https://www.debuggex.com/r/cqDse9Gs59bM0YkN -[Match Carrier]: https://www.debuggex.com/r/YbIeQ_M4s88_9NHG +[Match Carrier]: https://www.debuggex.com/r/uQa_IeV9QnXtOpGI -[Match Carrier China Mobile]: https://www.debuggex.com/r/_oGTPFpiqUNdaP8t +[Match Carrier China Mobile]: https://www.debuggex.com/r/dbF9BmNrGrq4vvWi [Match Carrier China Unicom]: https://www.debuggex.com/r/n8onnyBbDV-hN7mU -[Match Carrier China Telecom]: https://www.debuggex.com/r/r3m8n91BeWXfncGO +[Match Carrier China Telecom]: https://www.debuggex.com/r/JBBaP5VO_yD7uDfU [Match Inmarsat (Satellite Communications)]: https://www.debuggex.com/r/Ewdta8YJfreoXguf