Regex expression for phone number

Im trying to create a regex to make sure my variable is in the format of a phone number

(xxx) xxx-xxxx

and was thinking, ([0-9][3]) [0-9][3]-[0-9][4]

Am I even close?

Yes, but you need to escape the parenthesizes and the [3] (both) and [4] should be {3} and {4}

your fast, like

/([0-9]/[3]/) [0-9](3)-[0-9](4)

Not quite.

\([0-9]{3}\) [0-9]{3}-[0-9]{4}
1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.