I'm using the following JavaScript code to create a regular expression to match a UK mobile number:
new RegExp("(\+44|0)7\d{9}", 'g');
However, I get an error in the console log saying:
Uncaught SyntaxError: Invalid regular expression: /(?:+44|0)7d{9}/: Nothing to repeat
Similar questions on StackOverflow point to a missing escaped character, but mine seem to be fine.
I have also tried without the global
flag.
Help would be greatly appreciated.