{"record":{"id":"b748b95028dd281d","repo":"kestra-io/kestra","slug":"invalid-regex-0-1-b748b9","errorCode":null,"errorMessage":"Invalid regex ''{0}'': {1}","messagePattern":"Invalid regex ''(.+?)'': (.+?)","errorType":"exception","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/filters/RegexReplaceFilter.java","lineNumber":73,"sourceCode":"                self.getName()\n            );\n        }\n\n        if (args.get(ARGUMENT_REPLACEMENT) == null) {\n            throw new PebbleException(\n                null,\n                MessageFormat.format(\"The argument ''{0}'' is required.\", ARGUMENT_REPLACEMENT),\n                lineNumber,\n                self.getName()\n            );\n        }\n\n        String regex = args.get(ARGUMENT_REGEX).toString();\n        String replacement = args.get(ARGUMENT_REPLACEMENT).toString();\n        try {\n            return RegexUtils.matcher(Pattern.compile(regex), input.toString()).replaceAll(replacement);\n        } catch (PatternSyntaxException e) {\n            throw new PebbleException(e, MessageFormat.format(\"Invalid regex ''{0}'': {1}\", regex, e.getDescription()), lineNumber, self.getName());\n        } catch (RegexUtils.RegexTimeoutException e) {\n            throw new PebbleException(e, e.getMessage(), lineNumber, self.getName());\n        }\n    }\n}\n","sourceCodeStart":55,"sourceCodeEnd":79,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/filters/RegexReplaceFilter.java#L55-L79","documentation":"Thrown by the 'regexReplace' Pebble filter when `Pattern.compile(regex)` raises a `PatternSyntaxException`. The message embeds the bad pattern and the JDK's description so you can locate the syntax fault.","triggerScenarios":"Unbalanced parentheses, illegal quantifiers, malformed character classes, or backslash escaping issues induced by Pebble's string parsing.","commonSituations":"Writing `\\.` in a Pebble literal (becomes `.`); copying a regex from JS/Python without re-escaping; using unsupported constructs.","solutions":["Double-escape metacharacters in Pebble: `\\\\.`, `\\\\d`, `\\\\s`.","Test the pattern in a Java regex tester first.","For complex patterns, store them in a variable/input to escape once."],"exampleFix":"# before\n{{ url | regexReplace(regex=\"\\.com\", replacement=\".org\") }}\n# after\n{{ url | regexReplace(regex=\"\\\\.com\", replacement=\".org\") }}","handlingStrategy":"validation","validationCode":"# Double-escape in Pebble literals:\n{{ s | regexReplace(regex=\"\\\\.\", replacement=\"_\") }}\n# Validate the pattern in a script task:\n# Pattern.compile(userPattern);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Double-escape regex metacharacters inside Pebble strings.","Test patterns in a Java regex tester.","Centralise complex patterns in variables/inputs to escape once."],"tags":["pebble-filter","regex-replace","invalid-regex","pattern-syntax","escaping"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}