Reputation: 3
I currently have this regex string and i am getting a Unterminated regular expression literal error in my react code
const check_number = /^[0]\d{10}$)|(^[\+]?[234]\d{12}$
does anyone know how to fix this.
Upvotes: 0
Views: 4014
Reputation: 13623
The problem is you have an invalid regular expression, for a number of reasons:
/
character at the endUpvotes: -1
Reputation: 521249
The exact syntax error is being caused by a missing /
ending delimiter (and a few other things). But, your regex has other problems. Use this version:
const check_number = /^(?:0\d{10}|[+]?[234]\d{12})$/
The above pattern matches phone numbers which either:
Upvotes: 1