title: Extracting comma-separated values in parenthesis
body: <p>I have a text file in the following format:  </p>
  
  <pre><code>0 (1, 10), (0, 5), (3, 40)  
  1 (2, 15), (1, 23), (2, 18), (4, 5), (3, 50)  
  2 (3, 100)  
  </code></pre>
  
  <p>The first number in every line is used for a specific purpose. Similarly, each of the integers in parenthesis is used for another specific purpose. Therefore, I am trying to extract each of these integers separately. This is what I have tried:  </p>
  
  <pre><code>BufferedReader br = new BufferedReader(new FileReader("test.txt"));
  String line = br.readLine();
  while (line != null) {
       String[] separate = line.split(", ");
       for (int i = 0; i &lt; patterns.length; i++) {
          String result = separate[i].replace("(", "").replace(")", "");
       }
  }  
  </code></pre>
  
  <p>While this does extract each integer, there is no distinction between the integers in brackets and the first one in the line. Also, this solution does not separate each line in the file.<br>
  Could someone please assist me with a better solution to this?</p>