Replacing a small chunk of a larger string
<p>So I've got the following code written to go through every Anchor, get it's href, and if it contains the old address, attempt to replace the old base with the new one. While there's obviously an issue long before this code with the site, i need a quick and dirty solution to this problem, so this code is what I'm going for.</p>

<p>So, the code below doesn't work. .Replace apparantly needs a full match, so it would find "foo" in the sentence "foo is good" but not "foo" in "fooIsGood".</p>

<pre><code>$('a').each(function() {
    var addressSwitch = $(this).attr("href");
    if  (addressSwitch){
        var test = addressSwitch.indexOf("http://www.oldaddress.com");
        if ( test == 0){
            addressSwitch.replace("http://www.oldaddress.com/", "www.newaddress.com");
            $(this).attr("href" , addressSwitch);
            }
        }
});
</code></pre>

<p>So, what would work?</p>

<p>Thanks in advance!</p>
