Telephone Number Validator Country Code Help

I have tried various combinations of RegEx to get this. For the most part it works except I can’t seem to figure out how to restrict the Country Code to 1 only. I am now attempting to go through the various number tests a little at a time. For just the first Item I have tried:
/^([1\s(])?/
/^([^2-9][\s(])?
Can you help please?

  **Your code so far**

function telephoneCheck(str) {
var regEx = /^([1\s\(])?[\d{3}]/
return regEx.test(str);
}

telephoneCheck("555-555-5555");
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36 Edg/99.0.1150.39

Challenge: Telephone Number Validator

Link to the challenge:

If the country code is included it will always be at the beginning of the string and will just be the number 1 with possibly a space after it. How would you write a regex that matches this?

Thank you for your reply, it is nice knowing I have support out there. After plugging in many different combinations, I was able to find the one that worked and I passed the test. Thank you again.

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