Details
-
Improvement
-
Status: Resolved
-
Low
-
Resolution: Fixed
-
None
Description
singleQuote uses `String.replaceAll ()` a lot in loop.
and 'String.replaceAll()' compiles the regular expression each time it is called.
public String replaceAll(String regex, String replacement) { return Pattern.compile(regex).matcher(this).replaceAll(replacement); }
It is suggested in javadoc (https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html#matches(java.lang.String,%20java.lang.CharSequence)) that it is efficient to reuse the pattern.