0

I want use bad-words module with Turkish characters but i cant use. How can i make this?

Sample:

var Filter = require("bad-words")

var filter = new Filter({ replaceRegex:  /[A-Za-z0-9가-힣_]/g }); 
//multilingual support for word filtering

filter.addWords('ğ', 'ü', 'ı', 'i', 'e', 'y');

filter.clean("Turkish: ğ ü ı English: i e y");

output: "Turkish: ğ ü ı English: * * *"

Try it on npm RunKit: https://npm.runkit.com/bad-words

Enes
  • 55
  • 1
  • 5
  • [This Answer](https://stackoverflow.com/a/150078/16940103) might help, using Unicode's instead of the characters. – SirDerRosen Sep 18 '21 at 23:01

2 Answers2

1

The bad-words library does not support non-ascii letters, as it uses the ascii \b for word-boundary. Non-ascii are not even considered letters.

You can see here a proposal for a fix.

rewritten
  • 16,280
  • 2
  • 47
  • 50
0

if the RegEx engine supports Unicode then you can try to match the unicode instead of characters. see here

LazyNekoDev
  • 13
  • 1
  • 5