Java - Write code to check if a string is Number via regex

Requirements

Write code to check if a string is Number via regex

Demo

//package com.book2s;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] argv) {
        String value = "123123";
        System.out.println(isNumber(value));
    }/*  ww  w .java 2s  .  co  m*/

    public static boolean isNumber(String value) {
        String regEx = "\\d+\\.{0,}\\d{0,}";
        Pattern pattern = Pattern.compile(regEx);

        Matcher matcher = pattern.matcher(value);

        boolean result = matcher.matches();
        return result;

    }
}

Related Exercise