I assume it has something to do with using a variable, when I test it online I don't use a variable and it works. I haven't used much regex so I could just be doing something silly too.
let home = 'testhome';
let currentHome = 'testhome (8)';
let re = new RegExp(home + ' \(\d+\)');
if (currentHome.match(re)) {
//no match
} else {
// this is the code executed
}
Any help appreciated. There could be multiple numbers in the brackets of currentHome
.