Tell us what’s happening:
Hi everyone ,
Can someone please explain what’s wrong wth the below expression
I would like to match the number 1 555 555 555
My regular expression is as below
var regxi = /\d?\s?(?(?=\d{3}))\d{3}[-)\s]\d{3}[-)\s]\d{4}[-)\s]/
Is it possible to use the ? quantifier with lookaheads? I think the issue is somewhere there…
Many Thanks
Your code so far
function telephoneCheck(str) {
// Good luck!
var regxi = /\d?\s?\(?(?=\d{3}\))\d{3}[-)\s]\d{3}[-)\s]\d{4}[-)\s]/;
return regxi.test(str);
}
telephoneCheck("1 555 555 5555");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/validate-us-telephone-numbers