function filterNum(str) {
re = /$|,|@|#|~|`|%|*|^|&|(|)|+|=|[|-|_|]|[|}|{|;|:|'|<|>|?||||!|$|./g;
return str.replace(re, '');
}
var str = 'Car Car Car';
var newstr = str.replace(/Car/g, 'Bus');
var str = 'Car Car Car';
var rep = 'Bus';
search = new RegExp('Car', 'g');
var newstr = str.replace(search, rep); // prints 'Bus Bus Bus'
var str = 'text image text image text image';
var newstr = str.replace(/t(.*?)t/gi, 'b'); /* b image b image b image */
var newstr = str.replace(/t(.*?)t/gi, '$1'); /* ex image ex image ex image */
Replace between two singe and double quote
newstr = str.replace(/'(.*?)'/gi, '<b>''+'$1'+''</b>'); /* replace between quote */
newstr = str.replace(/'(.*?)'/gi, '<b>''+'$1'+''</b>'); /* replace between double quote */
Replace commnets
newstr = str.replace(//*(.*?)*//gi, '<s>/*'+'$1'+'*/</s>'); /* replace */
newstr = str.replace(///(.*?)<br>/gi, '<s>//'+'$1'+'</s><br />'); /* replace */
Remove white space from both ends of a string
string = string.replace(new RegExp(/^s+/),''); // START
string = string.replace(new RegExp(/s+$/),''); // END
Remove white space from ends then 'www.' from the start.
string = string.replace(new RegExp(/^www./i),'');
Remove white (blank) space from a string
string Anthem = 'Star Spangled Banner';
Anthem = Anthem.Replace(' ', '');