replace Blank via regular expression - Android java.util.regex

Android examples for java.util.regex:Blank Remove

Description

replace Blank via regular expression

Demo Code

import android.util.Log;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static String replaceBlank(String str) {
        String dest = "";
        if (str != null) {
            Pattern p = Pattern.compile("\t|\r|\n");
            Matcher m = p.matcher(str);
            dest = m.replaceAll("");
        }//w w w  . ja  v  a  2  s  .c o  m
        return dest;
    }

}

Related Tutorials