SpringAntMatcherOrderCheck extends AbstractMethodDetection { @VisibleForTesting static String escapeRegExpChars(String pattern) { return pattern.replaceAll("([.(){}+|^$\\[\\]\\\\])", "\\\\$1"); }    }
@Test void escape_regexp_characters() { assertThat(escapeRegExpChars("")).isEmpty(); assertThat(escapeRegExpChars("abc")).isEqualTo("abc"); assertThat(escapeRegExpChars("a(b)c")).isEqualTo("a\\(b\\)c"); assertThat(escapeRegExpChars("a{b}c")).isEqualTo("a\\{b\\}c"); assertThat(escapeRegExpChars("a[b]c")).isEqualTo("a\\[b\\]c"); assertThat(escapeRegExpChars("a.b+c")).isEqualTo("a\\.b\\+c"); assertThat(escapeRegExpChars("a|b\\c")).isEqualTo("a\\|b\\\\c"); assertThat(escapeRegExpChars("a^b$c")).isEqualTo("a\\^b\\$c"); }
@Test void does_not_escape_ant_matcher_special_characters() { assertThat(escapeRegExpChars("a?c")).isEqualTo("a?c"); assertThat(escapeRegExpChars("a*c")).isEqualTo("a*c"); assertThat(escapeRegExpChars("a**c")).isEqualTo("a**c"); }