I would like to know how i could possibly create from a string a list of numbers that are side by side.
Input:
"This is a test 234 234 34 56 and possibly 34 not a good example 234,34"
I'm actually using this code that creates a list of all numbers in the string, but no separated.
public List getNumbers(String s) {
String str = s.replaceAll("[^-?0-9]+", " ");
return Arrays.asList(str.trim().split(" "));
}
Output i have:
["234", "234", "34", "56", "34", "234", "34"]
Output i would like to obtain:
["234 234 34 56","34","234 34"]
I really hope you guys could help me, Thank you. (I'm new here, and aren't english sorry if i'm doing something wrong )