Back to Intellij Community

ReplaceAllNonRegex

java/java-impl/resources/inspectionDescriptions/ReplaceAllNonRegex.html

2025.3-rc-2621 B
Original Source

Reports calls to String.replaceAll() where the first argument is a plain (non-regex) string literal and the replacement is also a plain string literal. In such cases using String.replace() is clearer and avoids the overhead of regular expressions.

Example:

"a,b,c".replaceAll(",", ";");

After the quick-fix is applied:

"a,b,c".replace(",", ";");

Note: the inspection only suggests the replacement when it is safe, i.e., when the pattern contains no regular expression meta-characters and the replacement contains no special characters used by regex replacement like $ or \.

New in 2026.1