且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

RegEx 有效的国际手机号码

更新时间:2023-02-21 14:06:48

从输入中去除除+"和数字以外的所有字符后,应该这样做:

After stripping all characters except '+' and digits from your input, this should do it:

^+[1-9]{1}[0-9]{3,14}$

如果您想更准确地了解国家/地区代码,请参阅列表中的此问题电话号码国家/地区代码

If you want to be more exact with the country codes see this question on List of phone number country codes

但是,我会尽量不要对我的验证过于严格.如果用户被告知他们的有效号码不可接受,他们会非常沮丧.

However, I would try to be not too strict with my validation. Users get very frustrated if they are told their valid numbers are not acceptable.