Javascript String replaceAll()
String.prototype.replaceAll = function( strTarget,/*www . j av a 2 s . c o m*/ strSubString ){ var strText = this; var intIndexOfMatch = strText.indexOf( strTarget ); while (intIndexOfMatch != -1) { strText = strText.replace( strTarget, strSubString ) intIndexOfMatch = strText.indexOf( strTarget ); } return(strText); }
String.prototype.replaceAll = function () { var search = new RegExp(arguments[0], "g"); return this.replace(search, arguments[1]); };