I have a URL like /admin/editblogentry?page=3&color=blue
I want to alter the 'page' in the url to 1 so that the url becomes
/admin/editblogentry?page=1&color=blue
What is the best way to accomplish this using javascript?
var s="/admin/editblogentry?page=3&color=blue"
var re=/(.*page=)(\d+)(&.*)*/
s.replace(re,"$11$3")
Assuming that the URL contains only one number (i.e. the page numbers), this is the simplest regex:
"/admin/editblogentry?page=3&color=blue".replace(/\d+/, 10001)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With