jquery or js: replace a link site-wide with another AND change to https
<p>I want to change every instance of</p>

<pre><code>http[s]://www.mydomain.com/test/index.php?this_page=foo
</code></pre>

<p>to</p>

<pre><code>https://www.mydomain.com/test/index.php?this_page=bar
</code></pre>

<p>I think its must be able to be done with <code>attr.replace</code> but I can't figure out the notation. How can I do this with jQuery or JavaScript?</p>

<p>EDIT:  it seems everyone so far is either missing the first part (http OR https changes to https) or the second part (foo to bar) :)  Sorry for confusion</p>
