check Decimals by Regex - Java java.util.regex

Java examples for java.util.regex:Match Number

Description

check Decimals by Regex

Demo Code


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

public class Main {

    public static boolean checkDecimals(String decimals) {
        String regex = "\\-?[1-9]\\d+(\\.\\d+)?";
        return Pattern.matches(regex, decimals);
    }/* ww w  .  j a  v  a  2s  .co m*/
}

Related Tutorials