is string a Number via regular expression - Android java.util.regex

Android examples for java.util.regex:Number Pattern

Description

is string a Number via regular expression

Demo Code

import android.graphics.Paint;
import android.text.TextUtils;
import android.widget.TextView;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static boolean isNumber(String str) {
        Pattern pattern = Pattern.compile("[0-9]*");
        Matcher match = pattern.matcher(str);
        if (match.matches() == false) {
            return false;
        } else {//from ww  w  .j  a  v  a  2 s . c  om
            return true;
        }
    }

}

Related Tutorials