Tobai
10-02-2008, 04:09 PM
I'm trying to modify a page's url tags. For some reason, I can't get it to reference digits.
Here's an original url: http://www.example.com/browse.php?page=1234
I'm tring to modify to: http://www.example.com/browse/page/1234/fix
This is what I'm using.
var links = document.getElementsByTagName('a');
for (i = 0; i < links.length; i++) {
links[i].href = links[i].href.replace('\/browse\.php\?page=', '\/browse\/page\/');
}
Above works but I can't append '/fix' to the end of that line. Normally, I would backreference
\/browse\.php\?page=(\d+)', '\/browse\/page\/\1\/fix'
But I can't capture those digits. Am I'm not escaping something? Should be simple.
Even if I just use '\/browse\.php\?page=\d+', it won't match the above url?
Here's an original url: http://www.example.com/browse.php?page=1234
I'm tring to modify to: http://www.example.com/browse/page/1234/fix
This is what I'm using.
var links = document.getElementsByTagName('a');
for (i = 0; i < links.length; i++) {
links[i].href = links[i].href.replace('\/browse\.php\?page=', '\/browse\/page\/');
}
Above works but I can't append '/fix' to the end of that line. Normally, I would backreference
\/browse\.php\?page=(\d+)', '\/browse\/page\/\1\/fix'
But I can't capture those digits. Am I'm not escaping something? Should be simple.
Even if I just use '\/browse\.php\?page=\d+', it won't match the above url?