Skip to content

Regex Rules

Regex rules let you transform text at display time, prompt-build time, or both. They are useful for cleaning model habits, adapting imported scripts, and experimenting with formatting without permanently changing stored messages.

What A Rule Can Touch

Rules are non-destructive. Pyre keeps the original message and applies the rule only when rendering the chat or assembling the prompt. Turn a rule off and the original text is back immediately.

Each rule chooses:

Option What it means
Stream User input, AI output, or both.
Stage Displayed text, prompt text sent to the model, or both.
Find A raw regex pattern or a /pattern/flags literal.
Replace Plain text, capture groups, or Pyre/ST-compatible match tokens.

Regex Syntax

The Find box accepts a normal regex pattern. You can also use /pattern/flags when importing or writing rules in a familiar script style.

Supported flags:

Flag Effect
i Ignore case.
g Replace every match instead of only the first.
m Multiline anchors.
s Dot matches newlines.

Replacements support $1 through $9 for capture groups, $0 or {{match}} for the full match, and $$ for a literal dollar sign. Trim strings follow SillyTavern semantics: they strip configured substrings from the matched text before reuse.

Preview Before Saving

The editor includes a live test box. Pick the stream, paste sample text, and Pyre previews the result as you type. Invalid patterns show an inline error and cannot be saved; if an imported rule later becomes invalid, it safely does nothing instead of crashing a chat.

Order Matters

Rules run top to bottom. A later rule sees the output from earlier rules, so drag rules into the exact order you want. Rule order syncs across your paired devices and travels in backups.

SillyTavern Import

Pyre imports SillyTavern regex-script JSON as a single script, an array, or a regexScripts wrapper. User-input and AI-output placements map to Pyre streams; display-only and prompt-only placements map to stages. Scripts that target streams Pyre does not have arrive disabled for review, so they never silently rewrite every message.

Re-importing skips equivalent duplicates and reports how many rules were imported, skipped, or imported disabled.

Included Default

Pyre ships with one practical default rule: Unwrap italics around dialogue. It cleans the common model pattern *"Hello."* so dialogue does not render as faint narration. The rule is display-only and AI-output-only; delete it if you do not want it.

See Also