filter First Zero by regular expression - Android java.util.regex

Android examples for java.util.regex:Digit Pattern

Description

filter First Zero by regular expression

Demo Code

import android.text.TextUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{


    public static String filterFirstZero(String str) {
        if (!str.contains(".")) {
            return str.replaceFirst("^0*", "");
        }/*from w ww.ja  v  a2 s. co m*/
        return str;
    }

}

Related Tutorials