I want to test if a string contains a word or not.
So, I have this regex expression:/\bde\b/gi
And, if my string is "Comida de cão", it works.
But, if I have a string like "Necessidade de adeus depois " it also matches the "de" in "necessidade", "adeus" and "depois".
Besides, when I try to match words with accents in a string like "é a vida", using the regex like this: /\bé\b/gi
nothing is found.
But if I search for a word with an accent in the middle it is found! So in the string "O nível" if I use the following regex expression /\bnível\b/gi
it matches the right word.
I've been searching similar issues but I still didn't manage to solve my problem.
Btw, here the first issue doesn't happen and it works as expected.
Thanks!
Edit: Added my code
var myRe = new RegExp("\\b" + query + "\\b","iu");
var match = myRe.test("Necessidade de adeus depois");