is Number by regular expression - Android java.util.regex

Android examples for java.util.regex:Number Pattern

Description

is Number by regular expression

Demo Code

import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.CharacterStyle;
import android.text.style.ForegroundColorSpan;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static boolean isNumb(String str) {
        Pattern pattern = Pattern.compile("[0-9]*");
        Matcher matcher = pattern.matcher(str);
        return matcher.matches();
    }//from  w  ww  . ja  va 2 s.c o  m

}

Related Tutorials