I can't find the magic formula to get my regex working in Javascript. let's say I have:
const branchnames = [
{ name:'WICO-29', key:1 },
{ name:'WICO-9', key:2 },
{ name:'wico-2', key:3 },
{ name:'wiCo-2: description', key:4 },
{ name:'WiCO-2 example ', key:5 },
{ name:'WiCO-2-dosomething', key:6 },
{ name:'wiCO-2, great', key:7 },
];
I would like to recover every names excepts for the first two. Hence I am looking for a regex looking for "wico-2" (not case sensitive), followed either by nothing or a non alphanumerical character. Following attempts didn't work...
const reg = new RegExp(/wico-2[ ,:-]?$/, "i"); // miss: 4,5,6,7
const reg = new RegExp(/wico-2\W/, "i"); // miss: 3
const reg = new RegExp(/wico-2\W?/, "i"); // wrong:1
const reg = new RegExp(/wico-2\W?$/, "i"); // only 3
branchnames.forEach( element => {
console.log ( element.name.match(reg));
});
any help ? thanks !

if (key > 2)?