Splitting a string into 3 strings each with its own delimiter JAVA
I am working on code where i need to split a string into 3 different
parts, each part would need its own delimiter to get the individual part
out. I am not good with regex and the tutorials i have looked at dont
really explain this well. So if you could push me in the right direction
and if you have an answer explain each part of it that would be great!.
My input is
1 imported bottle of perfume at 27.99
1 bottle of perfume at 18.99
1 packet of headache pills at 9.75
1 box of imported chocolates at 11.25
My desired output is to have 3 strings for each.
"1" "imported bottle of perfume" "27.99"
Code:
String pattern = "[(\\d)][(\\w)][(\\d)]";
String[] splits = data[i].split(pattern);
No comments:
Post a Comment