After searching for a function that searches for all occurrences of a string within a body of text and replaces it with another string, I decided to write my own so here it is:
function replace (search, replace, subject):String {
r = subject.split(search).join(replace);
if (r.indexOf(search) == -1) {
return r;
} else {
replace(search, replace, r);
}
}