Check if given string is numeric (-+0..9(.)0...9) : Digit Number « Regular Expressions « Java

Check if given string is numeric (-+0..9(.)0...9)


public class Main {

  public static boolean isNumeric(String string) {
      return string.matches("^[-+]?\\d+(\\.\\d+)?$");
  public static void main(String[] args) {
sysout isNumeric("123.123")


Related examples in the same category

1.Check if given string is a number (digits only)
2.Check if given string is number with dot separator and two decimals
3.Match number
4.Match a single digit
5.Matcher Pattern number
6.reduce To Alpha Numerics with Regex