validate Number using Regex - Android java.util.regex

Android examples for java.util.regex:Number Pattern

Description

validate Number using Regex

Demo Code


//package com.java2s;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static boolean validateNumber(String str) {
        Pattern pattern = Pattern.compile("[0-9]");
        Matcher matcher = pattern.matcher(str);

        return matcher.matches();
    }/*  w w  w . j a v a2s.c  om*/
}

Related Tutorials