is Number String by regular expressions: [0-9]* - Android java.lang

Android examples for java.lang:Integer

Description

is Number String by regular expressions: [0-9]*

Demo Code

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static int isNumString(String str) {
        Pattern p = Pattern.compile("[0-9]*");
        Matcher m = p.matcher(str);
        if (m.matches()) {
            return 1;
        } else {//from w ww .  ja va 2 s  .  co  m
            return 0;
        }
    }

}

Related Tutorials