{"record":{"id":"fc0b567ee5994aaf","repo":"SillyTavern/SillyTavern","slug":"invalid-find-regex","errorCode":null,"errorMessage":"Invalid Find Regex","messagePattern":"Invalid Find Regex","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"public/scripts/extensions/regex/index.js","lineNumber":1358,"sourceCode":" * @param {JQuery<HTMLElement>} editorHtml The editor HTML\n */\nfunction updateInfoBlock(editorHtml) {\n    const infoBlock = editorHtml.find('.info-block').get(0);\n    const infoBlockFlagsHint = editorHtml.find('#regex_info_block_flags_hint');\n    const findRegex = String(editorHtml.find('.find_regex').val());\n\n    infoBlockFlagsHint.hide();\n\n    // Clear the info block if the find regex is empty\n    if (!findRegex) {\n        setInfoBlock(infoBlock, t`Find Regex is empty`, 'info');\n        return;\n    }\n\n    try {\n        const regex = regexFromString(findRegex);\n        if (!regex) {\n            throw new Error(t`Invalid Find Regex`);\n        }\n\n        const flagInfo = [];\n        flagInfo.push(regex.flags.includes('g') ? t`Applies to all matches` : t`Applies to the first match`);\n        flagInfo.push(regex.flags.includes('i') ? t`Case insensitive` : t`Case sensitive`);\n\n        setInfoBlock(infoBlock, flagInfo.join('. '), 'hint');\n        infoBlockFlagsHint.show();\n    } catch (error) {\n        setInfoBlock(infoBlock, error.message, 'error');\n    }\n}\n\n// Common settings migration function. Some parts will eventually be removed\n// TODO: Maybe migrate placement to strings?\nfunction migrateSettings() {\n    let performSave = false;\n","sourceCodeStart":1340,"sourceCodeEnd":1376,"githubUrl":"https://github.com/SillyTavern/SillyTavern/blob/8172dcd0ee672d3cd9a5e5f7af134f91a45cd2b8/public/scripts/extensions/regex/index.js#L1340-L1376","documentation":"Thrown in the regex script editor's live Find Regex info-block updater when regexFromString(findRegex) returns falsy for the currently typed pattern. Unlike 56, this is interactive UI feedback — the message is shown via setInfoBlock as an error hint, not propagated as an exception. It signals the in-editor pattern is invalid.","triggerScenarios":"Typing an incomplete or malformed pattern in the Find Regex field (trailing slash with invalid flags, unclosed character class, unsupported flag); pasting a pattern with mismatched delimiters.","commonSituations":"Iteratively authoring a regex and hitting an intermediate invalid state; using PCRE-specific flags the JS engine rejects.","solutions":["Complete/fix the pattern so it compiles in JS (flags limited to gimsuyuUAX).","Remove unsupported flags or stray delimiter slashes.","Test the pattern in a JS console first: new RegExp(...) or regexFromString(...).","Clear the field to reset the hint (empty input is treated as info, not error)."],"exampleFix":"// before\nfindRegex: \"foo/xyz\"\n\n// after\nfindRegex: \"/foo/gi\"","handlingStrategy":"validation","validationCode":"import { regexFromString } from '../../../../utils.js';\nconst re = regexFromString(findRegex);\nif (!re) {\n    setInfoBlock(infoBlock, 'Invalid Find Regex', 'error');\n    return;\n}","typeGuard":"const isValidFindRegex = (input) => typeof input !== 'string' || input.length === 0 || Boolean(regexFromString(input));","tryCatchPattern":null,"preventionTips":["Use only JS-legal regex flags (gimsuyuUAX).","Test patterns in a JS console before pasting into the editor.","Empty the field to reset the hint rather than fighting an invalid intermediate state."],"tags":["regex","validation","ui","user-input"],"backgroundTag":null,"analyzedSha":"8172dcd0ee672d3cd9a5e5f7af134f91a45cd2b8","analyzedAt":"2026-08-13T07:48:40.832Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}