{"record":{"id":"ddc0fa2954c1df2e","repo":"neoclide/coc.nvim","slug":"pattern-s-not-supported","errorCode":null,"errorMessage":"pattern (?s) not supported","messagePattern":"pattern \\(\\?s\\) not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/snippets/util.ts","lineNumber":75,"sourceCode":"}\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 '^'\n    return '^'\n  })\n}","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/snippets/util.ts#L57-L93","documentation":"Python's (?s) inline flag (dot matches newline) is not supported by the JS regex converter used for snippet transforms. convertRegex throws early so snippets fail loudly at parse time instead of silently misbehaving. Raised while parsing ${var/regex/repl/} transforms.","triggerScenarios":"A snippet transform regex containing the inline flag (?s), e.g. ${1/(?s).*/x/}.","commonSituations":"Porting VS Code/UltiSnips snippets that rely on (?s) multiline matching.","solutions":["Remove (?s) from the regex.","In JS, use the s (dotAll) flag semantics by matching [\\s\\S] instead of '.', since transform regexes are compiled without flags.","Split the transform to avoid needing dotall matching.","Rewrite the replacement logic in the snippet differently."],"exampleFix":"// before\n'${1/(?s).*/x/}'\n// after\n'${1/[\\\\s\\\\S]*/x/}'","handlingStrategy":"validation","validationCode":"function regexIsPortable(pattern: string): boolean {\n  return !pattern.includes('(?s)')\n}","typeGuard":"null","tryCatchPattern":"try {\n  let js = convertRegex(pattern)\n} catch (e) {\n  if (String(e.message).includes('(?s)')) pattern = pattern.replace('(?s)', '').replace(/\\./g, '[\\\\s\\\\S]')\n}","preventionTips":["Replace (?s) with [\\s\\S] instead of dot.","Strip Python-only inline flags when porting snippets.","Lint snippet files for (?s)/(?x) flags.","Test transforms during CI."],"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"}