Here is the code :
str = str.replace(/abc/g, '');
or you can use this one :
var find = 'abcxyz';
var re = new RegExp(find, 'g');
str = str.replace(re, '');
or
function replaceAll(find, replace, str) {
return str.replace(new RegExp(find, 'g'), replace);
}
call the function :
replaceAll(find, replace, str);
No comments:
Post a Comment