Skip to content

Commit

Permalink
Spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
Cohee1207 committed Feb 6, 2025
1 parent 2611546 commit 43bac30
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions extensions/Regex.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# RegEx
# Regex

## What is it?

The RegEx extension lets the user automatically detect specific patterns in a strings of text (called 'sequences') and apply manipulations to them. It can be a powerful tool when used in conjuction with other SillyTavern features such as QuickReplies or STSCript, or simply a way to remove certain words from a chat.
The Regex extension lets the user automatically detect specific patterns in a strings of text (called 'sequences') and apply manipulations (replacements) to them. It can be a powerful tool when used in conjuction with other SillyTavern features such as [Quick Replies or STscript](/For_Contributors/st-script.md), or simply a way to remove certain words from a chat.

## Helpful Links

Expand All @@ -16,11 +16,13 @@ The RegEx extension lets the user automatically detect specific patterns in a st

## Prerequisites

- Install the "RegEx" extension from the "Download Extensions & Assets" menu in the Extensions panel (stacked blocks icon).
Regex is a built-in extension of SillyTavern, so no additional setup is required.

You may find its settings in the **<i class="fa-solid fa-cubes"></i> Extensions** panel.

## Common Use Cases

RegEx is often used to apply a find-replace function on certain words in the chat, to add markdown styles to certain words or sentence types, or to return a boolean value to an STScript.
RegEx is often used to apply a find-replace function on certain words in the chat, to add markdown styles to certain words or sentence types, or to return a boolean value to an STscript.

## Script List

Expand All @@ -34,7 +36,7 @@ RegEx is often used to apply a find-replace function on certain words in the cha
Below this is a list of your scripts with some action buttons.

- Drag handles (three horizontal bars to the left of the script name) let you drag/drop the scripts into any order you like.
- Primary on/off switch can be quickly toggled to enable or disable the script without changing anything else. Disabled scripts are shown with ~~strikethrough~~ styling. **If a script is disabled here, it will be untriggerable by a QuickReply or STScript.**
- Primary on/off switch can be quickly toggled to enable or disable the script without changing anything else. Disabled scripts are shown with ~~strikethrough~~ styling. **If a script is disabled here, it will be untriggerable by a Quick Reply or STscript.**
- 'Edit' (pencil) button will open the RegEx script editor.
- 'Move to scoped' (down arrow) will convert a global script to a scoped script and apply it to the current character. In reverse (up arrow), it would convert a scoped script to global.
- 'Export' will cause your browser to download an exported `.json` file of the Script, which can then be shared and imported into another instance of SillyTavern.
Expand All @@ -44,11 +46,11 @@ Below this is a list of your scripts with some action buttons.

![RegEx Editor](/static/extensions/regex-editor.png)

- **Test Mode** : This will open a comparison view at the top of the editor. Type some text into the 'Input' box, and the results of your RegEx script will be shown in the Output box. It is a valuable debug tool as it will uppdate the Output box in real time as you make changes to the script settings.
- **Test Mode** : This will open a comparison view at the top of the editor. Type some text into the 'Input' box, and the results of your RegEx script will be shown in the Output box. It is a valuable debug tool as it will update the Output box in real time as you make changes to the script settings.

- **Name** : The label for the script shown on the extension's script list. **This is also used to target the script when triggering it via slashcommand or STScript.**
- **Name** : The label for the script shown on the extension's script list. **This is also used to target the script when triggering it via slash command or STscript.**

- **Find Regex** : This is the Regular Expression that is used to detect your targeted text pattern. This is usually the most complex part of any RegEx script, and is the easiest place to make mistakes. Refer to the links at the top of the page for information how to write a RegEx sequence. This box can resolve the values of common SillyTavern macros (such as \{\{user\}\}, \{\{char\}\}, etc) if the 'Macros in Find Regex' is set to do so (see below).
- **Find Regex** : This is the Regular Expression that is used to detect your targeted text pattern. This is usually the most complex part of any RegEx script, and is the easiest place to make mistakes. Refer to the links at the top of the page for information how to write a RegEx sequence. This box can resolve the values of [common SillyTavern macros](/Usage/Characters/macros.md) (such as \{\{user\}\}, \{\{char\}\}, etc) if the 'Macros in Find Regex' is set to do so (see below).

- **Replace With**: This is what will replace the matched sequence. In a very simple example, if your 'Find Regex' is `apple`, and your 'Replace With' is `orange`, all instances of 'apple' would be automatically changed to 'orange' in any text where the script is applied.

Expand All @@ -64,7 +66,7 @@ Below this is a list of your scripts with some action buttons.
- 'Slash Commands': script will be run against the values inserted into prompt/chat by slash commands.
- 'World Info': script will be run on against contents of World Info entries as they are injected into the prompt. **Requires 'Alter Outgoing Prompt' to be checked (or both ephemerality boxes to be unchecked).**
- 'Reasoning': script will be run against the contents of the 'reasoning' object returned by Chat Completion API's like Gemini or Deepseek. If 'Alter Outgoing Prompt' is checked under Ephemerality, the script will also be applied to any reasoning blocks that are added into prompt in subsequent chat turns.
- **If everthing here is unchecked the script will never activate during normal chatting, but it can still be activated via slash command or STScript.**
- **If everthing here is unchecked the script will never activate during normal chatting, but it can still be activated via slash command or STscript.**

- **Min/Max Depth** : How far back in the chat history to look for strings to match with. Leave both blank to apply the script to the whole chat.

Expand All @@ -83,7 +85,7 @@ By default (when neither box here is checked) a RegEx script will directly edit

If you do not want this to happen, you can enable either of the checkboxes here to limit the RegEx script's affects to only the display or the outgoing prompt.

If only one of the boxes is checked, there will be no changes made to the chat file, but **only the checked item** will be get the changes. This means you will be seeing one thing, but the LLM will be seeing another. Use this carefully.
If only one of the boxes is checked, there will be no changes made to the chat file, but **only the checked item** will be changed. This means you will be seeing one thing, but the LLM will be seeing another. Use this carefully.

If both are selected, the script will function as normal in all ways EXCEPT it will not write any changes to the chat file.

Expand All @@ -93,4 +95,4 @@ While RegEx is commonly used as a simple Find/Replace tool, it can also be used

For example the 'Replace With' box could include a set of CSS rules and HTML to add a specific styled HTML element into your chat whenever a certain word is found. This will require the `Show <tags> in responses` box to be unchecked in the User Settings panel.

The script can also be set to never trigger during normal use, but could instead be triggered via slash command as part of a logic check inside an STScript. The 'Replace With' box would include a unique value the script recognizes to indicate if a logic check is true or false. This expands the utility of RegEx to the full capabilities of all slash commands, allowing for truly unlimited levels of control and automation based on the contents of the chat.
The script can also be set to never trigger during normal use, but could instead be triggered via slash command as part of a logic check inside an STscript. The 'Replace With' box would include a unique value the script recognizes to indicate if a logic check is true or false. This expands the utility of RegEx to the full capabilities of all slash commands, allowing for truly unlimited levels of control and automation based on the contents of the chat.

0 comments on commit 43bac30

Please sign in to comment.