Java Utililty Methods Regex String Replace Whitespace

List of utility methods to do Regex String Replace Whitespace

Description

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

Method

StringreplaceBlank(String str)
Filter the space tab etc...
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
Matcher m = p.matcher(str);
return m.replaceAll("");
StringreplaceBlank(String str)
replace Blank
if (str != null) {
    Pattern p = Pattern.compile("\t|\r|\n");
    Matcher m = p.matcher(str);
    return m.replaceAll("").trim();
return null;
StringreplaceBlank(String str)
replace Blank
if (str != null) {
    Pattern p = Pattern.compile("\\s*|\t|\r|\n");
    Matcher m = p.matcher(str);
    str = m.replaceAll("");
return str;
StringreplaceBlank(String str)
replace Blank
String dest = "";
if (null == str) {
    return "esolving error!";
if (str != null) {
    Pattern p = Pattern.compile("\\s*|\t|\r|\n");
    Matcher m = p.matcher(str);
    dest = m.replaceAll("");
...
StringreplaceWhitespace(final String value, final boolean stripExtras)
Replaces all "whitespace" characters from the specified string with space characters, where whitespace includes \r\t\n and other characters
return replaceWhitespace(value, " ", stripExtras); 
StringreplaceWhitespace(final String value, final boolean stripExtras)
Replaces all "whitespace" characters from the specified string with space characters, where whitespace includes \r\t\n and other characters
return replaceWhitespace(value, " ", stripExtras); 
StringreplaceWhitespace(String searchTerm)
Replaces whitespace characters with underline.
String replaceTerm = "";
if (searchTerm == null) {
    return replaceTerm;
Pattern searchPattern = Pattern.compile(SEARCH_STRING);
String[] result = searchPattern.split(searchTerm);
replaceTerm = result[0];
for (int i = 1; i < result.length; i++) {
...
StringreplaceWhiteSpaces(final String value, final String replaceBy)
Replace white space characters (1..n) by the given replacement string
return PATTERN_WHITE_SPACE_MULTIPLE.matcher(value).replaceAll(replaceBy);
StringreplaceWhitespaces(String inString, String with)
replace Whitespaces
return WHITESPACE_PATTERN.matcher(inString).replaceAll(with);
StringreplaceWhitespaces(String inString, String with)
replace Whitespaces
return WHITESPACE_PATTERN.matcher(inString).replaceAll(with);