I have the following regex
string.match(/(?<notification_ID>\d+)/g)
In Chrome this works fine, but in FireFox this throws an exception
SyntaxError: invalid regexp group
I tried the solution given by JavaScript regular expression exception (Invalid group) by removing the ?
mark.
So my Regex became
$location.path().match(/(<notification_ID>\d+)/g)
However, now it returns null
.
What I want is to return an notification ID based on a string
Eg. https://example.com/here-comes-a-path/#!/notification-14 should return 14
How can I make the regex so it will work among all browsers?
If you are using Chrome this snippet will work
var string = 'https://example.com/here-comes-a-path/#!/notification-14';
console.log(string.match(/(?<notification_ID>\d+)/g))