I have a string that matches this regular expression: ^.+:[0-9]+(\.[0-9]+)*/[0-9]+$ which can easily be visualized as (Text):(Double)/(Int). I need to split this string into the three parts. Normally this would be easy, except that the (Text) may contain colons, so I cannot split on any colon – but rather the last colon.
The .* is greedy so it already does a pretty neat job of doing this, but this wont work as a regular expression into String.split() because it will eat my (Text) as part of the delimiter. Ideally I’d like to have something that would return a String[] with three strings. I’m 100% fine with not using String.split() for this.
Why don’t you just use a straight up regular expression?
Or similar. The pattern
^(.*):([\d\.]+)/(\d+)$assumes that you actually have values in all three positions, and will allow just a period/fullstop in the double position, so you may want to tweak it to your specifications.