Java Regex String Replace Whitespace replaceBlank(String str)

Here you can find the source of replaceBlank(String str)

Description

Filter the space tab etc...

License

Apache License

Parameter

Parameter Description
str a parameter

Declaration

public static String replaceBlank(String str) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    /**/*from  w w w.ja va2 s .  c o  m*/
     * Filter the space tab etc...
     *
     * @param str
     * @return
     */
    public static String replaceBlank(String str) {
        Pattern p = Pattern.compile("\\s*|\t|\r|\n");
        Matcher m = p.matcher(str);
        return m.replaceAll("");
    }
}

Related

  1. replaceBlank(String str)
  2. replaceBlank(String str)
  3. replaceBlank(String str)
  4. replaceWhitespace(final String value, final boolean stripExtras)