Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

号码类正则表达式 #4

Open
JCHappytime opened this issue Mar 26, 2021 · 0 comments
Open

号码类正则表达式 #4

JCHappytime opened this issue Mar 26, 2021 · 0 comments

Comments

@JCHappytime
Copy link
Owner

1. 电话号码(国内)

reg=/\d{3}-\d{8}|\d{4}-\{7,8}/

reg.test(028-86768888);   // =>true

【思考】如何格式化手机号码,隐藏中间四位数字。见格式化相关

2. 18位身份证号码

reg=/^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X|x)$/

reg.test('62162019970419321X');   // =>true
reg.test('62162019970419321');   // =>false

3. 国内普通手机号码

reg=/^1[34578]\d{9}$/

reg.test('18082910023');   // =>true
reg.test('122233243');   // =>false

4. 国内邮政编码

reg=/[1-9]\d{5}(?!\d)/

reg.test(620000);   // =>true
reg.test(6200001);   // =>false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant