Can anyone help me to split the string by number Eg: "I Need 5000 points" is the string I want "5000" from that string.
I tried many ways like:
//split the string by RegExp:
String array = string.split(".*\\d.")
I am getting the output but its not what I expect
Output:
array[0] = ""
array[1] ="points
Can anyone help me to find the proper solution?
Pattern pattern = Pattern.compile("\\d+");
Matcher matcher = pattern.matcher("I Need 5000 points");
while (matcher.find()) {
System.out.println(matcher.group());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With