I'm writing a regex that validates a phone number and want it to to either have 3 digits matching or 3 digits wrapped in parentheses. It fails if there is only a closing parentheses but matches if there is an open one by itself. I can't figure out why. Here is the regex:
let phoneRegex = //(\d{3}|\(\d{3}\))( ?|-?)(\d{3})( ?|-?)(\d{4})//
let sampleNumber = (908-525-5565