I'm looking for a regex to split the following strings
red 12478
blue 25 12375
blue 25, 12364
This should give
Keywords red, ID 12478
Keywords blue 25, ID 12475
Keywords blue IDs 25, 12364
Each line has 2 parts, a set of keywords and a set of IDs. Keywords are separated by spaces and IDs are separated by commas.
I came up with the following regex: \s*((\S+\s+)+?)([\d\s,]+)
However, it fails for the second one. I've been trying to work with lookahead, but can't quite work it out
I am trying to split the string into its component parts (keywords and IDs)
The format of each line is one or more space separated keywords followed by one or more comma separated IDs. IDs are numeric only and keywords do not contain commas.
I'm using Java to do this.
,afterredhas to be there, but not afterblue?