Skip to content

Commit

Permalink
Merge pull request VincentSit#15 from VincentSit/js_compatibility
Browse files Browse the repository at this point in the history
Optimize the compatibility of some regular expressions in JavaScript.
  • Loading branch information
VincentSit authored Jan 10, 2019
2 parents 030fb8e + c110f58 commit 88f72a3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
27 changes: 14 additions & 13 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}$`][匹配北京船舶通信导航有限公司(海事卫星通信)]
Expand Down Expand Up @@ -136,6 +136,9 @@ https://www.debuggex.com (PCRE 在线视觉化)

## 更新日志

#### 2019.01.10
- 优化部分正则表达式在 JavaScript 中的兼容性。

#### 2019.01.07
- 添加 165 号段支持。

Expand Down Expand Up @@ -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

Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 88f72a3

Please sign in to comment.