Search docs...

Start typing to search documentation

Chat Guide

Regex Scripts

Automatic find-and-replace at four points in the pipeline.

Modes

A regex script runs at one of four points:

ModeRuns on
editinputYour message, before it enters the prompt.
editoutputThe model's reply, before it is saved.
editprocessThe whole prompt during assembly.
editdisplayThe rendered message; storage stays untouched.

Script fields

Each script is a pattern, a replacement (with $1-style capture references), and flags. Scripts attach to characters, so cards can ship their own text pipeline.

editdisplay is the safe playground: it only changes what you see, never what is stored or sent, so a broken pattern cannot corrupt a chat.

Meta directives

Directives inside the script body control execution: an order tag fixes the position in the pipeline when multiple scripts run in the same mode, and action directives move or transform the matched text instead of a plain replace.

text
<order 10>
@@move_top

Example

Convert asterisk emphasis into markup in the display layer:

text
IN:  \*(.+?)\*
OUT: <em>$1</em>

SillyTavern regex scripts import as part of character cards and run under the same modes.

Regex Scripts in UnoRouter