I’m using regexr.com to test my regex and I’m testing all the tests that should return true. However, for some reason it matches on the website, but when I run the tests on FCC, it doesn’t work. What’s wrong?
I know my code won’t pass every test, but I want to know why there’s a descrepancy between the site I’m using to check the regex and FCC’s tests.
function telephoneCheck(str) {
// Check if valid pattern
let pattern = /1?\s?(\(\d{3}\)|\d{3})[-\s]*\d{3}[-\s]*\d{4}/;
if(str.match(pattern)){return true;}
return false;
}
telephoneCheck("555-555-5555");