var token = "\r\n";var newToken = " ";var oldStr = "This is a test\r\nof the emergency broadcasting\r\nsystem.";newStr = oldStr.split(token).join(newToken);
// Find, Replace, Case// i.e "Test to see if this works? (Yes|No)".replaceAll('(Yes|No)', 'Yes!');// i.e.2 "Test to see if this works? (Yes|No)".replaceAll('(yes|no)', 'Yes!', true);String.prototype.replaceAll = function(_f, _r, _c){
var o = this.toString();var r = '';var s = o;var b = 0;var e = -1;if(_c){ _f = _f.toLowerCase(); s = o.toLowerCase(); }
while((e=s.indexOf(_f)) > -1){r += o.substring(b, b+e) + _r;s = s.substring(e+_f.length, s.length);b += e+_f.length;}
// Add Leftoverif(s.length>0){ r+=o.substring(o.length-s.length, o.length); }
// Return New Stringreturn r;};
/foo/g - Refers to the all string to replace matching the case sensitive
/foo/gi - Refers to the without case sensitive and replace all For Eg: (Foo, foo, FoO, fOO)