I know that the following regex will match \"red\", \"green\", or \"blue\".
red|green|blue
Is there a straightforward way of making it mat
var href = '(text-1) (red) (text-3) (text-4) (text-5)';
var test = href.replace(/\((\b(?!red\b)[\s\S]*?)\)/g, testF);
function testF(match, p1, p2, offset, str_full) {
p1 = "-"+p1+"-";
return p1;
}
console.log(test);
var href = '(text-1) (frede) (text-3) (text-4) (text-5)';
var test = href.replace(/\(([\s\S]*?)\)/g, testF);
function testF(match, p1, p2, offset, str_full) {
p1 = p1.replace(/red/g, '');
p1 = "-"+p1+"-";
return p1;
}
console.log(test);