Hello, I thought this was trivial but couldn't solve it out :(
I want to change a param passed in mu url with javascript.
var fullurl = window.location;
//do dome stuff to find var url.
fullurl.replace(/sort:.*\/direction:.*/g,'sort:' + url + '/direction:asc');
Basically there is a url like: http://example.com/article/ or http://example.com/article/sort:author/direction:asc
I the first case I don't want anything to be changed. In the second I want to replace the sort:
with sort:url
.
the above code doesn't seem to do anything. I think the problem is that the regexp isn't parsed, and it returns a url with .*
and \/
inside
any help? thanks