[Solved] Regex for string that validates for a number which may include decimal and for a particular length [closed]


Run this code and test with all your inputs.It should solve your scenario.

String regex = "^[0-9.]{5}$";
Pattern pattern = Pattern.compile(regex);
String name= "123.4";
Matcher matcher = pattern.matcher(name);
System.out.println(matcher.matches());

1

solved Regex for string that validates for a number which may include decimal and for a particular length [closed]