开发者

RegEx for Telephone # with country code included

I need to validate a telephone number in the following format

xx-xxx-xxxxxx

x can only be a digit and all x开发者_开发技巧 can't be zero.


[1-9]\d-\d{3}-\d{6}

Assuming only the first digit needs to be non-zero.

[1-9]{2}-[1-9]{3}-[1-9]{6}

if none of the digits can be zero.

Anchor with ^ at the beginning and $ at the end as necessary.


x can only be a digit and all x can't be zero.

^(?!0{2})[0-9]{2}-(?!0{3})[0-9]{3}-(?!0{6})[0-9]{6}$

It will not accept all zero country code or all zero telephone number.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜