All the statements below worked on https://regex101.com.
The first one had an error and looks like js doesn’t support lookbehinds.
/^(?:1\s|1)?(\(?)\d{3}(?(?<=\(\d{3})\)\s?\d{3}-\d{4}|(?:\d{7}|-\d{3}-\d{4}|\s\d{3}\s\d{4}))$/
I refactored it without lookbehinds:
/^(?:1\s|1)?(?(?=\(\d{3}\))\(\d{3}\)\s*\d{3}-\d{4}|(\d{3}(.)\d{3}\2\d{4}|\d{10}))$/
Again, I put this into regex101 and it worked.
Here’s what I got from the console:
SyntaxError: Invalid regular expression: /^(?:1\s|1)?(?(?=\(\d{3}\))\(\d{3}\)\s*\d{3}-\d{4}|(\d{3}(.)\d{3}\2\d{4}|\d{10}))$/: Invalid group