Hi there everyone,
I am having some difficulties getting a regular expression to work. I have a line of text with 5 numbers.I want to ignore the first number, and grab the other 4 numbers. Here is what the text I am dealing with looks like.
1681 12.33754513 7.066246057 6.079261254 2.953020134
1171 9.676875527 12.76832461 2.725877787 9.275756545
Here is the regular expression I came up with(I'm a noob at regexs).
Pattern p = Pattern.compile("\\D+(\\d+)(\\d+)(\\d+)(\\d+)");
Matcher m = p.matcher(lineString2);
if(m.find()){
double nr1 = Double.parseDouble(m.group(1));
double nr2 = Double.parseDouble(m.group(2));
double nr3 = Double.parseDouble(m.group(3));
double nr4 = Double.parseDouble(m.group(4));
Can anyone help me out with this? I really appreciate any and all thoughts/comments/suggestions.
Bonus Points: If anyone could suggest a way that if a line contains N/A or NaN I could just make that value 0 and still grab the actual numbers aswell.
1838 73.32185886 100 80.13204361 N/A
1298 86.31226455 NaN N/A N/A