this question is different because the first function errors, but the other identical functions work fine.
Question: Why does the first function fail, but not the second? ...in these JS
Regexfunctions, from a 3rd party lib used toparse float/intsetc with the help of the regex function.
Please advise how do I troubleshoot fix this error?

According to https://developer.mozilla.org/en-US/docs/Glossary/Syntax_error
Once the browser encounters a syntax error, it stops parsing the script and reports the error immediately.
You can run these two snippets in DevTools console to see it in action:
Hope this helps!