+ 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

29th Dec 2019, 3:32 AM
Great Pyramids 🏜
Great Pyramids 🏜 - avatar
2 ответов
+ 4
String s = "Hello World20"; String s1 = s.replaceAll("[^0-9]+", ""); System.out.println(s1.length());
29th Dec 2019, 4:12 AM
elias sharafi
elias sharafi - avatar