javaregexstringsubstringstring-utils

Java: How to RegEx or Substring Utils this String?


"Current Peak :   830           300"

How can I get hold of the two numbers, but without the spaces. (There are 5 or more spaces in between each substring)

Using apache's StringUtils I got so far:

String workUnit =
StringUtils.substringAfter(thaString,
":");

This gives back:

"830           300"

but still with a lot of spaces and not separated.


Solution

  • Untested, but this should give you your two numbers:

    String[] workUnits = StringUtils.split(StringUtils.substringAfter(thaString, ":"));