So, the challenge is that we are trying to detect if a string matches a fixed phone number pattern, this is a simple string pattern.
The pattern is:
A slight variation of one of the other answers, but I believe the built-in character class should be slightly faster than a custom one:
return /^\d{3}-\d{3}-\d{4}$/.test(phoneNumber);