Here's the string format I'm working with: 123:23:21
The three separate numbers could range from 1 to 99999, it's essentially a key to represent a set of data.
I need to extract each of the separate numbers
- The first before the colon "123"
- The second between the first colon "32" and last colon
- The third after the last colon "21"
I've found a few answers (below), but don't provide enough info for a complete amateur to do what I need too.
- Regular expression to match word pairs joined with colons
- Regex to find a string after the last colon
- Regex: Question mark and colon
These are completely wrong but I've tried variations of ^\w+:$
, ^:\w+:$
, ^:\w+$
.
Can anyone give me a heads up as to how to implement this in Java? Could be regex or substring.