It also incorrectly matches:
(
((555) 555-5555
()
(555 555-5555
1
1 1 555 555-5555
It's important to consider both positive and negative constraints for the resulting regular language.
This should be a bit closer, but also not entirely accurate for certain edge cases:
/^(1 )?(\d{3}|\(\d{3}\))[ -]?\d{3}[ -]?\d{4}/
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It also incorrectly matches:
(
e.g.((555) 555-5555
()
e.g.(555 555-5555
1
e.g.1 1 555 555-5555
It's important to consider both positive and negative constraints for the resulting regular language.
This should be a bit closer, but also not entirely accurate for certain edge cases: