title: Parsing a table using regex - Java
body: <p>I'm parsing the following <code>AWS</code> cost instance table:</p>
  
  <pre><code>m1.small    1   1   1.7     1 x 160    $0.044 per Hour
  m1.medium   1   2   3.75    1 x 410    $0.087 per Hour
  m1.large    2   4   7.5     2 x 420    $0.175 per Hour
  m1.xlarge   4   8   15      4 x 420    $0.35 per Hour
  </code></pre>
  
  <p>There's a file with those costs:</p>
  
  <pre><code>input = new Scanner(file);
  String[] values;
  while (input.hasNextLine()) {
      String line = input.nextLine();
      values = line.split("\\s+"); // &lt;-- not what I want...
      for (String v : values)
          System.out.println(v);
  }
  </code></pre>
  
  <p>However that gives me:</p>
  
  <pre><code>m1.small
  1
  1
  1.7
  1
  x
  160
  $0.044
  per
  Hour
  </code></pre>
  
  <p>which is not what I want ... A corrected parsed <code>values</code> (with the right regex) would look like this:</p>
  
  <pre><code>['m1.small', '1', '1', '1.7', '1 x 160', '$0.044', 'per Hour']
  </code></pre>
  
  <p>What would be the right <code>regex</code> in order to obtain the right result? One can assume the table will have always the same pattern. </p>