I have two strings like these
var temp = 'xx-y1 xx-y2 xx-y3';
var temp1 = 'zz-y1 zz-y2 zz-y3';
I wanna replace all the words started with "xx-" and "zz-" pattern and for this purpose I do this.
temp.replace(/\bxx-\S+/g, '');
temp.replace(/\bzz-\S+/g, '');
now my question is how can I have a single function and just call it?
I try to test this but it doesn't work!!!
func = function(str, pattern) {
return str.replace(RegExp('\b' + pattern + '\S+', 'g'), '');
}