Javascript String Replace similar to Php string Replace in repeated words

by Prabakaran 2012-05-03 12:49:12


var str="Welcome-To-Hiox-Softwares-Pvt-Ltd";
document.write(str.replace("-"," "));
String.prototype.replaceAll = function(strTarget,strSubString){
var strText = this;
var intIndexOfMatch = strText.indexOf( strTarget );
while (intIndexOfMatch != -1){
strText = strText.replace( strTarget, strSubString )
intIndexOfMatch = strText.indexOf( strTarget );
}
return( strText );
}
strReplaceAll2 = str.replaceAll( "-", " " )
alert( strReplaceAll2 );


1180
like
0
dislike
0
mail
flag

You must LOGIN to add comments