function str_replace ( search, replace, subject ) {	// Replace all occurrences of the search string with the replacement string
	// 
	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   improved by: Gabriel Paderni
	if(!(replace instanceof Array)){
		replace=new Array(replace);
		if(search instanceof Array){//If search	is an array and replace	is a string, then this replacement string is used for every value of search
			while(search.length>replace.length){
				replace[replace.length]=replace[0];
			}
		}
	}
	if(!(search instanceof Array))search=new Array(search);
	while(search.length>replace.length){//If replace	has fewer values than search , then an empty string is used for the rest of replacement values
		replace[replace.length]='';
	}
	if(subject instanceof Array){//If subject is an array, then the search and replace is performed with every entry of subject , and the return value is an array as well.
		for(k in subject){
			subject[k]=str_replace(search,replace,subject[k]);
		}
		return subject;
	}
	for(var k=0; k<search.length; k++){
		var i = subject.indexOf(search[k]);
		while(i>-1){
			subject = subject.replace(search[k], replace[k]);
			i = subject.indexOf(search[k],i);
		}
	}
	return subject;
}
 
  
function str_replace(search, replace, subject) {
return subject.split(search).join(replace);
}
взято отсюда
http://derclops.ya.ru/replies.xml?item_no=115&ncrnd=2365
Ага, тока у него массивы передавать можно =)
Отличная функция! )
Спасибо! помогло)
Так надо:
MemHOST, цуко, гений!
Алгоритм не должен приводить к зависанию. Попробуйте сделать
var s = str_replace("A", "A", "A");
Ну вот.. хотел поюзать, заменить один символ в не длинной строке - и огнелис как давай ом-ном-ном озу..... и больше я его не видел....