title: Convert String into a two dimensional array
body: <p>I try to convert this string </p>
  
  <blockquote>
    <p>s=[[4, 2, 2, 4], [3, 4, 5, 6], [6, 7, 8, 9], [3, 2, 1, 4]]<br/>
    into a two dimensional array like this<br/>
    {4, 2, 2, 4},<br/>
    {3, 4, 5, 6},<br/>
    {6, 7, 8,9},<br/>
    {3, 2, 1, 4}<br/></p>
  </blockquote>
  
  <p>by use this code</p>
  
  <pre><code> int e=s.replaceAll("\\[", "").replaceAll(" ","").replaceAll("],","]").length();
          String[] rows1 = s.replaceAll("\\[", "").replaceAll(" ","").replaceAll("],","]").substring(0, e-2).split("]");
  
          String[][] matrix1 = new String[4][4]; 
          int r1 = 0;
          for (String row1 : rows1) {
              matrix[r1++] = row1.split(",");
          }
  
          System.out.println(Arrays.deepToString(matrix1));
  </code></pre>
  
  <p>But is have problem like this </p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
        at test.main(test.java:94)</p>
  </blockquote>
  
  <p>Can you help me find a solution?</p>