I have a to rewrite a part of an existing C#/.NET program using Java. I’m not that fluent in Java and am missing something handling regular expressions and just wanted to know if I’m missing something or if Java just doesn’t provide such feature.
I have data like
2011:06:05 15:50\t0.478\t0.209\t0.211\t0.211\t0.205\t-0.462\t0.203\t0.202\t0.212
The Regex pattern I’m using looks like:
?(\d{4}:\d{2}:\d{2} \d{2}:\d{2}[:\d{2}]?)\t((-?\d*(\.\d*)?)\t?){1,16}
In .NET I can access the values after matching using match.Group[3].Captures[i].
In Java I haven’t found anything like that. matcher.group(3) just returns an empty string.
How can I achieve a behaviour like the one I’m used to from C#?
As I mentioned in the comments, Java will only return the last value of a multiple valued group fit. So you should first use regex to isolate the last part of your string with the values:
strg = "0.478\t0.209\t0.211\t0.211\t0.205\t-0.462\t0.203\t0.202\t0.212"and then just split around the tabs:
String[] values = strg.split("\\t");