Enes
Enes

Reputation: 55

How can I use Turkish characters in Nodejs module Regex

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

Upvotes: 0

Views: 295

Answers (2)

rewritten
rewritten

Reputation: 16435

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.

Upvotes: 1

LazyNekoDev
LazyNekoDev

Reputation: 13

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

Upvotes: 0

Related Questions