当前位置: 动力学知识库 > 问答 > 编程问答 >

Regex to validate phone number which is in the US Format

问题描述:

This question already has an answer here:

  • A comprehensive regex for phone number validation

    36 answers

网友答案:

You can use this negative lookahead based regex:

^(?![0()-]+$)\(?(\d{3})\)?[-. ]?(\d{3})[-. ]?(\d{4})$

RegEx Demo

  • (?![0()-]+$) is a negative lookahead that says fail the match if matches only [0()-] character till the end.
分享给朋友:
您可能感兴趣的文章:
随机阅读: