I want to check if a user input is a valid double number (X.XXXXX).
This is my code:
if(textField.getText().matches("^[0-9][.]+[0-9]$"))
{
System.out.println("This is a double");
}
If the user inputs 5.5
, println
gets executed. If user inputs 5.55
or a number with more numbers after the dot (5.5XXX...
) it will not match.
How can I define a regex that matches all numbers after the dot, no matter how many?