How to split a string with certain delimiters in java
<p>I have a string as</p>

<pre><code>[Ian Wood P. M. Visscher]
[Ian Wood L. Mengersen]
[Ian Wood]
[P. M. Visscher Ian Wood].
</code></pre>

<p>I want to write this string into two dimensional array. (i.e)String</p>

<pre><code>a[0][0]=Ian Wood ,
a[0][1]=P. M. Visscher,
a[1][0]=Ian Wood,
a[1][1]=L. Mengersen and so on.
</code></pre>

<p>Every time when I would give input, the names in the string will change.How do I split it and store it in the above form in the array. Please suggest any idea . Thanks in advance.Following is the code I worked on,but does not split properly.</p>

<pre><code>String[] parts = output.split(" ");
String[][] table = new String[parts.length / 2][2];
for (int i = 0, r = 0; r &lt; table.length; r++) {
table[r][0] = parts[i++];
table[r][1] = parts[i++];
}
System.out.println(java.util.Arrays.deepToString(table));
</code></pre>
