How about reading data line by line, splitting each line on space and using each part as Quantity
argument? Something like:
String[] tmp = line.split("(?<=\\d)\\s*(?=[a-zA-Z])");
Quantity(Double.parse(tmp[0]), tmp[1]);
this will split on place that has zero or more whitespaces surrounded from left side with digit and from right with chracter from range a-z or A-Z
Demo:
String[] lines = { "12.553 mg", "23floz", "5 oz", "23kg", "45 kg", };
for (String line : lines) {
String[] tmp = line.split("(?<=\\d)\\s*(?=[a-zA-Z])");
System.out.println(tmp[0] + ":" + tmp[1]);
}
output:
12.553:mg
23:floz
5:oz
23:kg
45:kg