+ 1
How to check for the number of numbers in an inputed string?
For example i want to check if the entered string has 2 numbers. How can i do it? Ex- input: helloworld20 Output: 2
2 ответов
+ 4
String s = "Hello World20";
String s1 = s.replaceAll("[^0-9]+", "");
System.out.println(s1.length());