Test, validate and match regular expressions
Matches North American 10-digit phone numbers with an optional parenthesized area code and consistent separators. The backreference (\2) ensures the same separator (space, dot, or hyphen) is used between both digit groups, so '123-456-7890', '(123) 456 7890', '123.456.7890', and '1234567890' all match, while mixed separators like '123-456.7890' do not. Capture groups also extract the area code, exchange, and line number for easy parsing. Commonly used for form validation.