I would like to make an url rewriter in javascript, my problem is that if i make something like:
var str='/test/service-34.htm',
exp='/test/service-[0-9]*.htm';
console.log(str.match(exp));
I would get ‘/test/service-34.htm’ as response, so if i can’t make a replace like:
/test/service-34.htm -> test.php?service=$1
Try:
It is important to create a backreference to use the
[0-9]part in your replacement. Also you might want to use+instead of*to make the number required.