Description
There is a bug in JDK 1.4's String.replaceAll in which quoted (\Q..\E) patterns that contain a backslash are not matched correctly.
This should work, but does not in JDK 1.4 (JDK 1.5 is OK):
assert "axa".equals("a\\a".replaceAll("\\Q\\\\E", "x"))
The workaround is to have RegexUtils.quote not put backslashes inside the quote, but instead escape out of the quote and use a backslash to escape the backslash.
So this does work in JDK 1.4 (and JDK 1.5 too of course):
assert "axa".equals("a\\a".replaceAll("\\Q\\E\\\\\\Q\\E", "x"))
Attachments
Issue Links
- is depended upon by
-
GROOVY-3285 Implement String.replace(CharSequence, CharSequence), a JDK 1.5 method, for backwards compatibility
- Closed