// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.util.regex.*;

public class DCheck {
    private static Pattern p = Pattern.compile("[-]?[0-9]+[.]?[0-9]*");
    private static boolean doubleCheck(String s) {
        return p.matcher(s).matches();
    }
    private static void test(String s) {
        System.out.println("#" + s + "# " + doubleCheck(s));
        return;
    }
    public static void main(String[] args) {
        test("123");
        test("123.456");
        test("-123");
        test("-123.456");
        test("123.");
        test("12.34.56");
        test("1 2 3");
        test("-");
        test("");
    }
}
