问题描述:

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.
相关阅读:
Top