String.split() usually used in simpler scenarios where separator and formatting are more consistent, and when you don’t know how many elements you are going to split.
In your use case, the usual old regular expression is used. You know the formatting of a string, and you know that you want to collect three values. Try the following:
Pattern p = Pattern.compile("(.+):([0-9\\.]+)/([0-9]+)$");
Matcher m = p.matcher(myString);
if (m.find()) {
String myText = m.group(1);
String myFloat = m.group(2);
String myInteger = m.group(3);
}
source
share