# Search And Replace Problem

**URL:** <https://forum.kirupa.com/t/search-and-replace-problem/197023>\
**Category:** flash\
**Created:** [August 12, 2006, 10:49pm UTC](https://forum.kirupa.com/t/search-and-replace-problem/197023 "2006-08-12T22:49:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![saveth](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@saveth](https://forum.kirupa.com/u/saveth)\
**Post date:** [August 12, 2006, 10:49pm UTC](https://forum.kirupa.com/t/search-and-replace-problem/197023/1 "2006-08-12T22:49:39Z")

</div>

I’m having trouble setting my text box correctly after I do a search and replace. Should be obvious but my variable that I’m passing in is called songTitle and the text box instance name is songTitle\_txt. Here is my current code. Any help would be appreciated.

```auto

function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        songTitle = xmlNode.childNodes[8].childNodes[0];
        songTitle = songTitle.searchReplace(" - ", ": ");
        songTitle = songTitle_txt.text.toUpperCase();
    } else {
        content = "file not loaded!";
    }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("http://www.crylounge.com/shoutcast.php");

String.prototype.searchReplace = function(find, replace) {
    var myarray = this.split(" ");
    for (var i = 0; i<myarray.length; i++) {
        if (myarray* == find) {
            myarray* = replace;
        }
    }
    return myarray.join(" ");
};

```

Thanks,  
Saveth
