Skip to content

Instantly share code, notes, and snippets.

@dclstn
Created June 19, 2026 12:35
Show Gist options
  • Select an option

  • Save dclstn/33207501beb97cad8a3aaf845218cb43 to your computer and use it in GitHub Desktop.

Select an option

Save dclstn/33207501beb97cad8a3aaf845218cb43 to your computer and use it in GitHub Desktop.
BetterTTV — Using regular expressions in Highlight & Blacklist Keywords

Using Regular Expressions in BetterTTV Keywords

BetterTTV's Highlight Keywords and Blacklist Keywords support full regular expressions, in addition to plain words and phrases. This lets you match flexible patterns instead of a single fixed word.

Syntax

Wrap your pattern in ~/ and /, with optional flags after the closing slash:

~/pattern/flags

This is the same style as a JavaScript regular expression literal.

Examples

Entry Matches
~/(cat|dog)s?/i cat, Cat, dogs, DOGS, ...
~/\bgg\b/i the standalone word "gg" (not "eggs")
~/!(give|raffle)/i !give or !raffle commands
~/[A-Z]{5,}/ shouting (5+ uppercase letters in a row)

Flags

Standard JavaScript regex flags work, for example:

  • i — case-insensitive
  • g — global
  • u — unicode

Where it works

Regex applies to every Target type in the keyword tables:

  • Message — tested against the message text
  • Username — tested against the sender's name
  • Badge — tested against the user's badges

Both the Highlight Keywords and Blacklist Keywords tables support it.

Notes

  • Patterns are validated for safety. Expressions that could cause catastrophic backtracking are ignored, so a "bad" pattern simply won't match anything rather than freezing your chat.
  • If a pattern isn't wrapped in ~/ /, it is treated as a normal word/phrase match (with BetterTTV's usual wildcard and exact-match rules).
  • Remember to escape regex special characters when you want them matched literally.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment