It's a recurring topic, but I haven't been able to find a good solution. I have words I need to match with the content of my page with regex in javascript, and those absolutely have to be words, not parts of words. However some of them start or end with a letter from this set: [zżźćńółęąśŻŹĆĄŚĘŁÓŃA].
Word boundaries obviously do not work with these at the end or the beginning. Replacing them with their unicode counterparts doesn't seem to work either.
Right now I'm using a hack: I assigned numbers from 1 to 9 to lowercase letters from the list, and I'm checking if any letter in a word matches any key from the character dictionary. If it does, it gets replaced with a number, then I replace it the same way in the content I need to match against.
It kinda works, but it's a half-measure, and it means the regex is no longer case-sensitive, which I would really like to have.
Surely there has to be a clean solution?
EDIT as asked in a comment...
/\bbudyń\b/g
budyń budyńasda
Matches bold, should match the first word and leave the other one intact.
/\bósemka\b/g
ósemka asdaósemka
Likewise.