0

I am trying to write regular expression for the below string

"+1(332)313-1231"

this is my regular expression

var regex=new RegExp('^+1([1-9]{3})+[1-9]{3}+-[1-9]{4}')

how can I correct the regular expression inorder to test the string with above format?

  • E.g., [`var regex = /^\+1\([0-9]{3}\)[0-9]{3}-[0-9]{4}$/`](https://regex101.com/r/JqYiLB/1). – Wiktor Stribiżew Apr 21 '18 at 20:12
  • That regex wont work. You have methachar literals that need to be escaped, otherwise, they are regex group symbols `()`. Probably won't find that info in an exact duplicate that isn't ... –  Apr 21 '18 at 20:13

0 Answers0