I want to make a word boundary \b check for matching words that also work if there are certain special characters in the word getting matched, such as Ø, but preferably not characters like ! or ?. Since the special character is at the end of the word, the \b sees it as being "open space" and therefore matches the word without it actually being a free-standing word.
Is this possible to do?
Right now this check matches both words, but i would like it to only match the word with "Ford".
const nodes = [{
textContent: "Ford is the best"
}, {
textContent: "Fordørgen is the best"
}];
const variable = 'Ford';
const regex = new RegExp('\\b' + variable + '\\b');
const matches = nodes.filter(function(node) {
return regex.test(node.textContent);
});
console.log(matches);