Regular Expressions 101

Community Patterns

1...56789...575

Match a phone number formatted using North American Numbering Plan (NANP)

0

Regular Expression
Python

r"
^[ ]*(?:(?:\+)?1)?[ ]*(\()?(?:[2-9][0-9]{2})(?(1)\))[ ]*(?:-|\.)?[ ]*(?:[2-9][0-9]{2})[ ]*(?:-|\.)?[ ]*[0-9]{4}[ ]*$
"
gm

Description

Submitted by Nishant Misra - 3 years ago (Last modified 3 years ago)