SyntaxFix
Write A Post
Hire A Developer
Questions
Add a word boundary \b at the end of the regex:
\b
/^(\([0-9]{3}\) |[0-9]{3}-)[0-9]{3}-[0-9]{4}\b/
if the space after ) is optional:
)
/^(\([0-9]{3}\)\s*|[0-9]{3}-)[0-9]{3}-[0-9]{4}\b/