Class Filter

Profanity Filter class.

Constructors

Properties

exclude: string[] = []

List of words to exclude from filter.

list: string[] = []

List of words to filter.

placeHolder: string = '*'

Character used to replace profane words.

regex: RegExp = ...

Regular expression used to sanitize words before comparing them to blocklist.

replaceRegex: RegExp = ...

Regular expression used to replace profane words with placeHolder.

splitRegex: RegExp = ...

Regular expression used to split a string into words.

Methods

  • Add word(s) to blocklist filter / remove words from whitelist filter

    Parameters

    • Rest...words: string[]

      Word(s) to add to blocklist

    Returns void

  • Evaluate a string for profanity and return an edited version.

    Parameters

    • input: string

      String to filter.

    Returns string

  • Determine if a string contains profane language.

    Parameters

    • string: string

      String to evaluate for profanity.

    Returns boolean

  • Add words to allowlist filter

    Parameters

    • Rest...words: string[]

      Word(s) to add to allowlist.

    Returns void

  • Replace a word with placeHolder characters;

    Parameters

    • string: string

      String to replace.

    Returns string