mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Regex matching for keys and secondary keys
This commit is contained in:
@@ -194,6 +194,13 @@ class WorldInfoBuffer {
|
|||||||
* @returns {boolean} True if the string was found in the buffer
|
* @returns {boolean} True if the string was found in the buffer
|
||||||
*/
|
*/
|
||||||
matchKeys(haystack, needle, entry) {
|
matchKeys(haystack, needle, entry) {
|
||||||
|
// If the needle is a regex, we do regex pattern matching and override all the other options
|
||||||
|
const keyRegex = parseRegexFromString(needle);
|
||||||
|
if (keyRegex) {
|
||||||
|
return keyRegex.test(haystack);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise we do normal matching of plaintext with the chosen entry settings
|
||||||
const transformedString = this.#transformString(needle, entry);
|
const transformedString = this.#transformString(needle, entry);
|
||||||
const matchWholeWords = entry.matchWholeWords ?? world_info_match_whole_words;
|
const matchWholeWords = entry.matchWholeWords ?? world_info_match_whole_words;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user