Java Utililty Methods Regex String Replace All

List of utility methods to do Regex String Replace All

Description

The list of methods to do Regex String Replace All are organized into topic(s).

Method

StringreplaceAllPerLine(Pattern pattern, String value, String replacement)
replace All Per Line
final StringBuilder result = new StringBuilder();
try (Scanner scanner = new Scanner(value)) {
    while (scanner.hasNextLine()) {
        final String line = scanner.nextLine();
        result.append(pattern.matcher(line).replaceAll(replacement));
        result.append("\n");
return result.toString();
StringreplaceAllStrictly(String src, String search, String replacement, boolean entirelyMatch, boolean caseSensitive)
ignore regex
if (search == null) {
    if (src == null) {
        return replacement; 
    } else {
        return src; 
} else {
    if (src == null) {
...
StringreplaceAllTotal(String what, Pattern p, String replacement)
replace All Total
return p.matcher(what).replaceAll(replacement);
StringreplaceAllTotal(String what, String expr, String replacement)
Version of the String.replaceAll(what, expr, replacement) which ignores new line breaks and case sensitivity
return Pattern.compile(expr, Pattern.CASE_INSENSITIVE | Pattern.DOTALL).matcher(what)
        .replaceAll(replacement);