{"record":{"id":"33dba251202b5f84","repo":"languagetool-org/languagetool","slug":"unexpected-exception-when-processing-regexp-in-rul","errorCode":null,"errorMessage":"Unexpected exception when processing regexp in rule with id %s.","messagePattern":"Unexpected exception when processing regexp in rule with id (.+?)\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/rules/patterns/RegexPatternRule.java","lineNumber":126,"sourceCode":"\n        boolean startsWithUpperCase = patternMatcher.start() == 0 && Character.isUpperCase(text.charAt(patternMatcher.start()));\n        RuleMatch ruleMatch = new RuleMatch(this, sentenceObj, markStart, markEnd, patternMatcher.start(), patternMatcher.end(),\n                processedMessage, shortMessage, startsWithUpperCase, false, processedSuggestionsOutMsg, true);\n        if (regexFilter != null) {\n          RegexRuleFilterEvaluator ruleFilterEvaluator = new RegexRuleFilterEvaluator(regexFilter);\n          RuleMatch filteredMatch = ruleFilterEvaluator.runFilter(getFilterArguments(), ruleMatch, sentenceObj, patternMatcher);\n          if (filteredMatch != null) {\n            matches.add(ruleMatch);\n          }\n        } else {\n          matches.add(ruleMatch);\n        }\n\n        startPos = patternMatcher.end();\n      } catch (IndexOutOfBoundsException e){\n        throw new RuntimeException(String.format(\"Unexpected reference to capturing group in rule with id %s.\", this.getFullId()), e);\n      } catch (Exception e) {\n        throw new RuntimeException(String.format(\"Unexpected exception when processing regexp in rule with id %s.\", this.getFullId()), e);\n      }\n    }\n    return matches.toArray(RuleMatch.EMPTY_ARRAY);\n  }\n\n  @NotNull\n  private List<Pair<Integer, Integer>> getClausePositionsInMessage(Pattern pattern, String message) {\n    Matcher matcher = pattern.matcher(message);\n    List<Pair<Integer, Integer>> clausePositionsInMessage = new ArrayList<>();\n    while (matcher.find()) {\n      clausePositionsInMessage.add(Pair.of(matcher.start(), matcher.end()));\n    }\n    return clausePositionsInMessage;\n  }\n\n  private String processMessage(Matcher matcher, String message, List<Pair<Integer, Integer>> backReferences,\n                                List<Pair<Integer, Integer>> suggestions, List<Match> matches) {\n","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/rules/patterns/RegexPatternRule.java#L108-L144","documentation":"Wrapper exception from the regex rule engine: while applying a regex-based rule to a sentence, an unexpected low-level exception (regex processing, filter evaluation, or suggestion replacement) escaped. The original cause is chained, and the rule id in the message identifies which XML rule triggered it; the error is in the rule definition or its filter, not in the calling code.","triggerScenarios":"Thrown at languagetool-core/src/main/java/org/languagetool/rules/patterns/RegexPatternRule.java:126 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the chained cause exception to identify the underlying failure","Test the rule's regular expression in isolation to find syntax or back-reference errors","If the rule uses a <filter>, verify the filter class and its arguments are correct"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}