{"record":{"id":"d10eb84cb6b0d151","repo":"neoclide/coc.nvim","slug":"pattern-z-not-supported","errorCode":null,"errorMessage":"pattern \\z not supported","messagePattern":"pattern \\\\z not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/snippets/util.ts","lineNumber":72,"sourceCode":"  // options from ultisnips context\n  noExpand?: boolean\n  [key: string]: boolean | number | string | undefined\n}\n\nconst stringStartRe = /\\\\A/\nconst conditionRe = /\\(\\?\\(\\w+\\).+\\|/\nconst commentRe = /\\(\\?#.*?\\)/\nconst namedCaptureRe = /\\(\\?P<\\w+>.*?\\)/\nconst namedReferenceRe = /\\(\\?P=(\\w+)\\)/\nconst regex = new RegExp(`${commentRe.source}|${stringStartRe.source}|${namedCaptureRe.source}|${namedReferenceRe.source}`, 'g')\n\n/**\n * Convert python regex to javascript regex,\n * throw error when unsupported pattern found\n */\nexport function convertRegex(str: string): string {\n  if (str.indexOf('\\\\z') !== -1) {\n    throw new Error('pattern \\\\z not supported')\n  }\n  if (str.indexOf('(?s)') !== -1) {\n    throw new Error('pattern (?s) not supported')\n  }\n  if (str.indexOf('(?x)') !== -1) {\n    throw new Error('pattern (?x) not supported')\n  }\n  if (str.indexOf('\\n') !== -1) {\n    throw new Error('pattern \\\\n not supported')\n  }\n  if (conditionRe.test(str)) {\n    throw new Error('pattern (?id/name)yes-pattern|no-pattern not supported')\n  }\n  return str.replace(regex, (match, p1) => {\n    if (match.startsWith('(?#')) return ''\n    if (match.startsWith('(?P<')) return '(?' + match.slice(3)\n    if (match.startsWith('(?P=')) return `\\\\k<${p1}>`\n    // if (match == '\\\\A') return '^'","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/snippets/util.ts#L54-L90","documentation":"convertRegex translates Python (VS Code snippet) regex syntax into JavaScript regex for snippet transforms. Python's \\z (and \\Z semantics) have no JS equivalent, so the function rejects the pattern up front rather than producing wrong replacements. Called when parsing ${var/regex/repl/} transforms.","triggerScenarios":"A snippet transform whose regex contains the literal \\z, e.g. ${1/(\\z)/x/}.","commonSituations":"Snippets copied from other editors or documentation that use Python-specific regex escapes.","solutions":["Remove the \\z or \\Z escape from the transform regex.","Rewrite the transform using standard JS-compatible anchors/matches.","Drop the transform and use a plain placeholder if the regex is unnecessary.","Ask the snippet author for a portable variant."],"exampleFix":"// before\n'${1/(\\\\z)/x/}'\n// after\n'${1/(z)/x/}'","handlingStrategy":"validation","validationCode":"function regexIsPortable(pattern: string): boolean {\n  return !pattern.includes('\\\\z')\n}","typeGuard":"null","tryCatchPattern":"try {\n  let js = convertRegex(pattern)\n} catch (e) {\n  if (String(e.message).includes('\\\\z')) pattern = pattern.replace(/\\\\[zZ]/g, '')\n}","preventionTips":["Audit snippets ported from Python engines for \\z escapes.","Keep transform regexes to JS-compatible syntax.","Test all snippet transforms at load time.","Prefer simple alternation over Python-specific escapes."],"tags":["snippets","regex","transform"],"backgroundTag":"unsupported-regex-pattern","analyzedSha":"50e974d9692461a69147d5cab146a8d3e439abe4","analyzedAt":"2026-08-31T11:17:23.966Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}