TODO
If the input is a string, the filter will be set to a predefined swear preset.
const filter = Filter('PG13')
Field | Description |
---|---|
* |
Include all possible negatively-associated words. |
PG13 |
Less words filtered, minimum for a child-friendly environment. |
If you want to configure a certain preset of of censored words, you can pass a configuring object like follows. All configurative attributes are optional.
const filter = Filter({
patterns: [],
words: [],
})
Define your own set of regex-defined patterns.
RegexCensor provides an oversimplified regex construction.
For example, hello
will automatically filter hellllllooooooo
, he11o
, but also h3110
. End and/or start a word with *
if the substring after or before doesn't matter. hello*
will censor many hellos
and hellowwwwwwssssss
.
Adds the patterns to the filter, to quickly add regex arrays to the filter, use Filter.add_many(RegExp[])
Adds a word to the filter, to quickly add arrays of words to the filter, use Filter.add_many_words(RegExp[])
Checks one or several strings for profanity defined by the Filter. Returns true
if any string triggers the patterns and false
otherwise, to quickly check arrays with the filter, use Filter.check_many(string[]) : boolean
Checks one or several strings for profanity defined by the Filter. Returns all emitted profane words.
Checks one or several strings for profanity defined by the Filter. Returns all emitted regex pattern sources.
Replaces profanity in the string with asterisks.