Skip to content

Commit e7fdc8c

Browse files
committed
support windows paths in RegexMatcher
1 parent d783ced commit e7fdc8c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

code-assert/src/test/java/guru/nidi/codeassert/pmd/RegexMatcher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public RegexMatcher(List<Pattern> patterns) {
3333
public static Matcher<String> matchesFormat(String format) {
3434
final List<Pattern> patterns = new ArrayList<>();
3535
for (final String line : format.split(lineSeparator())) {
36-
patterns.add(Pattern.compile("\\Q" + line.replace("%d", "\\E\\d+\\Q") + "\\E"));
36+
patterns.add(Pattern.compile("\\Q" + line.replace("%d", "\\E\\d+\\Q").replace("\\", "\\\\") + "\\E"));
3737
}
3838
return new RegexMatcher(patterns);
3939
}
@@ -80,6 +80,6 @@ protected void describeMismatchSafely(String item, Description description) {
8080
}
8181

8282
private String pattern(Pattern p) {
83-
return p.pattern().replace("\\Q", "").replace("\\E", "").replace("\\d+", "%d");
83+
return p.pattern().replace("\\Q", "").replace("\\E", "").replace("\\d+", "%d").replace("\\\\", "\\");
8484
}
8585
}

0 commit comments

Comments
 (0)