{"record":{"id":"8ae52b4621af21d1","repo":"neoclide/coc.nvim","slug":"pattern-x-not-supported","errorCode":null,"errorMessage":"pattern (?x) not supported","messagePattern":"pattern \\(\\?x\\) not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/snippets/util.ts","lineNumber":78,"sourceCode":"const 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 '^'\n    return '^'\n  })\n}\n\n/**\n * Action code from context or option","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/snippets/util.ts#L60-L96","documentation":"Python's (?x) verbose/extended-mode inline flag is unsupported in the JS regex conversion for snippet transforms. The converter throws at parse time to avoid compiling a pattern whose whitespace/comment semantics would differ in JavaScript.","triggerScenarios":"A snippet transform regex containing (?x) or free-spacing formatting (whitespace/comments in the pattern).","commonSituations":"Snippets copied from Python-based snippet engines (UltiSnips) that use verbose regexes.","solutions":["Remove (?x) and collapse the pattern to a single line.","Strip insignificant whitespace and comments from the pattern manually.","Simplify the transform regex.","Test the snippet after edit via snippetManager to confirm parsing succeeds."],"exampleFix":"// before\n'${1/(?x) foo \\\\d+ /x/}'\n// after\n'${1/ foo \\\\d+ /x/}'","handlingStrategy":"validation","validationCode":"function regexIsPortable(pattern: string): boolean {\n  return !pattern.includes('(?x)')\n}","typeGuard":"null","tryCatchPattern":"try {\n  let js = convertRegex(pattern)\n} catch (e) {\n  if (String(e.message).includes('(?x)')) pattern = collapseVerboseRegex(pattern) // strip whitespace/comments\n}","preventionTips":["Flatten verbose regexes to a single line before porting.","Remove comments/whitespace from patterns.","Prefer simple transforms in snippets.","Validate snippets with the parser before distribution."],"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"}