The regular expression looks for: three numeric characters \d{3} OR | a left parenthesis \(, followed by three digits \d{3}, followed by a close parenthesis \), in a non-capturing group (?:) followed by one dash, forward slash, or decimal point in a capturing group () followed by three digits \d{3} followed by the match remembered in the (first) captured group \1 followed by four digits \d{4} The click event activated when the user presses Enter sets the value of phoneInput.value.

Enter your phone number (with area code) and then click "Check".
The expected format is like ###-###-####.