Java examples for java.util.regex:Match Number
check Decimals by Regex
//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*/ }