Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

/
^((1\s?)?(\d{3}|\(\d{3}\)))[\-|\s]?\d{3}[\-|\s]?\d{4}$
/
gm

Description

Regex for validating us telephone number as per freecodecamp testcases-

Submitted by Yashdeep Hinge - 9 years ago