I have the following RegEx to replace the entire querystring for a string with a new one:
"http://www.google.com?bar=1".replace(/\?.*/, "?foo=2")
This works only if there is a querystring. The following will not work:
"http://www.google.com".replace(/\?.*/, "?foo=2")
How do I make the RegEx match both situations?