web-mech / badwords

A javascript filter for badwords
MIT License
618 stars 325 forks source link

Words with accent not moderated #86

Open GuillaumeDgr opened 3 years ago

GuillaumeDgr commented 3 years ago

Hi,

With french-badwords-list added, all accented words are not filtered... Any help pls ? (https://github.com/darwiin/french-badwords-list#readme) Thanks

TripleFun-Damian commented 2 years ago

You can remove accents beforehand with the code:

myString.normalize('NFD').replace(/\p{Diacritic}/gu, '')
GuillaumeDgr commented 2 years ago

Hi, many thanks ! But I have an error : Parsing error: Invalid regular expression: /\p{Diacritic}/: Invalid escape

TripleFun-Damian commented 2 years ago

That's from 2021 onwards, so it would depend on where you're executing it (Node/browser). You can try one of the other options here: https://stackoverflow.com/a/37511463 such as:

str.normalize("NFD").replace(/[\u0300-\u036f]/g, "")