Java tutorial
//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); } }