I am attempting to use a regular expression in Javascript but I am getting an error:
SyntaxError: Invalid quantifier ?.
The weird thing is that this exact regular expression works on this website. But when executed in javascript it fails?
Paste this ^/courses(/[a-z0-9\-]+){2,3}(/|\.jsp)?(\?.*)?$ into the website and see it works.
What am I doing wrong?
var res = "/courses/applied-finance-postgraduate-qualifications/graduate-certificate-in-corporate-finance-3/?stid=b951f"
.replace( new RegExp("^/courses(/[a-z0-9\-]+){2,3}(/|\.jsp)?(\?.*)?$"), "abc");