I20210314-1800
tagged this
13 Mar 11:29
Improve the "Use String.replace() instead of String.replaceAll() when
possible" cleanup
- to apply it also when there are escaped meta chars in the regex and/or
the replacement,
- to use chars when both arguments are Strings of length 1 and
- to handle Pattern.quote() and Matcher.quoteReplacement()
Examples:
s.replaceAll("\\.", "<\e\\\ \\&>") => s.replace(".", "<\\ &>")
s.replaceAll("\\.", "/") => s.replace('.', '/')
s.replaceAll(Pattern.quote(a), Matcher.quoteReplacement(b))
=> s.replace(a, b)
The preview has been adapted to cover these improvements.
More tests have been added and also the preview has been added to the
tests.
Property-based jqwik tests creating 20,100,000 random samples to back up
the verification of the correctness of the toPlainString() method has
been attached to the bug report (these tests are too slow to be run as
regular tests):
https://bugs.eclipse.org/bugs/attachment.cgi?id=285626
Change-Id: Ia9320494b77a972d19757bdfd6914b42b9911491
Signed-off-by: Holger Voormann <eclipse@voormann.de>