remove Empty Char by regular expression - Android java.util.regex

Android examples for java.util.regex:Blank Remove

Description

remove Empty Char by regular expression

Demo Code

import android.text.TextUtils;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static String removeEmptyChar(String src) {
        if (src == null || src.length() == 0)
            return src;
        return src.replaceAll("[\r]*[\n]*[ ]*[ ]*", "");
    }/*  www  . j  ava2  s  .co  m*/

}

Related Tutorials