From 5a45e64999088662430831f5c4962a5a85bf0f92 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Tue, 7 May 2024 02:52:22 +0200 Subject: [PATCH] Regex matching for keys and secondary keys --- public/scripts/world-info.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index 22e40073e..ce46a40e2 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -194,6 +194,13 @@ class WorldInfoBuffer { * @returns {boolean} True if the string was found in the buffer */ 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 matchWholeWords = entry.matchWholeWords ?? world_info_match_whole_words;