I want to extract numbers from a string like:
str="good_mor9ni13ng_23guys ";
The output should be an array [9,13,23]
.
How should I proceed?
You could do it like this:
List<String> matches = new ArrayList<String>();
Matcher m = Pattern.compile("[0-9]+").matcher("good_mor9ni13ng_23guys");
while (m.find()) {
matches.add(m.group());
}