title: Extract numbers between square bracket and separated by comma
body: <p>I have an input file:</p>
  
  <pre><code>U10:%x[-2,1]
  U11:%x[-1,1]
  U12:%x[0,1]q
  U13:%x[1,1]
  U14:%x[2,1]
  U15:%x[-2,1]/%x[-1,1]
  U16:%x[-1,1]/%x[0,1]
  U17:%x[0,1]/%x[1,1]
  U18:%x[1,1]/%x[2,1]
  
  U20:%x[-2,1]/%x[-1,1]/%x[0,1]
  U21:%x[-1,1]/%x[0,1]/%x[1,1]
  U22:%x[0,1]/%x[1,1]/%x[2,1]
  </code></pre>
  
  <p>Now I want to read line by line and extract the number to assign to variable <code>i,j</code> such that:</p>
  
  <pre><code>i=-2, j=1;
  i=-1, j=1;
  i=0, j=1;
  i=1, j=1;
  i=2, j=1;
  i=-2, j=1; then i=-1, j=1;
  i=-1, j=1; then i=0, j=1;
  etc.
  </code></pre>
  
  <p>I am thinking about regular expressions, but strangely this one give no match:</p>
  
  <pre><code>FileReader frr = new FileReader("/Users/home/Documents/input.txt");
  BufferedReader brr = new BufferedReader(frr);
  String linee;
  
  while ((linee = brr.readLine()) != null) {
      String pattern = "\\[(.*?)\\]";
      Pattern regex = Pattern.compile(pattern);               
      Matcher regexMatcher = regex.matcher(linee);                
      System.out.println(regexMatcher.group());
  }
  brr.close();
  </code></pre>
  
  <p>And if I use split, it also return very strange results:</p>
  
  <pre><code>String[] listItems = linee.replaceFirst("^\\[", "").split("(\\(\\d+\\))?\\]?(\\s*,\\s*\\[?|$)");
  System.out.println(listItems);
  </code></pre>
  
  <p>result:</p>
  
  <pre><code>[Ljava.lang.String;@c3bb2b8
  </code></pre>
  
  <p>etc.</p>
  
  <p>How should I do the above task? </p>