check Digit by Regex - Java java.util.regex

Java examples for java.util.regex:Match Number

Description

check Digit by Regex

Demo Code


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

public class Main {

    public static boolean checkDigit(String digit) {
        String regex = "\\-?[1-9]\\d+";
        return Pattern.matches(regex, digit);
    }/*  w  w w. j  a  va 2 s. c  om*/
}

Related Tutorials