title: Java: Regex for Parsing Positive and Negative Doubles
body: <p>I am trying to parse doubles from a line of text. I found few lines of code that I thought was doing what I wanted. However, I discovered it would not parse negative doubles (would just parse them as positive). I am totally new to regex and its a little overwhelming. I was wonder if someone could explain the code below and tell me what each part means, and how I would modify it so it will parse both positive and negative doubles? Thanks in advance!</p>
  
  <pre><code>double nextDouble;
  Matcher matcher = Pattern.compile("(?!=\\d\\.\\d\\.)([\\d.]+)").matcher(line);
  if (matcher.find()) nextDouble = Double.parseDouble(matcher.group(1)));
  </code></pre>
  
  <p>EDIT: Here is an example of a line. 
  "104.44518717, 34.09785265, 103.39288764, 0.09813121, 0.00000000, -0.46612322, 4.68576504"</p>
  
  <p>It parses -0.46612322 as 0.46612322.</p>