Skip to content

Commit

Permalink
Unescape macros in regex WI key examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Cohee1207 committed Jan 7, 2025
1 parent 54e5c0c commit 94e2006
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Usage/worldinfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
order: 130
icon: globe
route: /usage/core-concepts/worldinfo/
templating: false
---

# World Info
Expand Down Expand Up @@ -64,20 +65,20 @@ An example of a use-case for advanced regex matching:
An entry/instruction that should be inserted, when char is doing a weather-related action

```js
/(?:\{\{char\}\}|he|she) (?:is talking about|is noticing|is checking whether|observes) (?:the )?(rainy weather|heavy wind|it is going to rain|cloudy sky)/i
/(?:{{char}}|he|she) (?:is talking about|is noticing|is checking whether|observes) (?:the )?(rainy weather|heavy wind|it is going to rain|cloudy sky)/i
```

For more information on Regex syntax and possibilities: [Regular expressions - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions)

###### Advanced Regex Per-Message Matching

ST prefixes every chat message in the WI scan buffer with `\{\{character name\}\}:` and after v1.12.6, concatenates prepends them using the character value 1 (`\x01`).
ST prefixes every chat message in the WI scan buffer with `character name:` and after v1.12.6, concatenates prepends them using the character value 1 (`\x01`).
This means you can match specific input or output from a certain character using a regex tied to that separation character.

For example, to match only the user saying "hello", you could use the following regex:

```js
/\x01\{\{user\}\}:[^\x01]*?hello/
/\x01{{user}}:[^\x01]*?hello/
```

##### Key Input
Expand Down

0 comments on commit 94e2006

Please sign in to comment.