title: How to split this string using Java Regular Expressions
body: <p>I want to split the string</p>
  
  <pre><code>String fields = "name[Employee Name], employeeno[Employee No], dob[Date of Birth], joindate[Date of Joining]";
  </code></pre>
  
  <p>to</p>
  
  <pre><code>name
  employeeno
  dob
  joindate
  </code></pre>
  
  <p>I wrote the following java code for this but it is printing only name other matches are not printing.</p>
  
  <pre><code>String fields = "name[Employee Name], employeeno[Employee No], dob[Date of Birth], joindate[Date of Joining]";
  
  Pattern pattern = Pattern.compile("\\[.+\\]+?,?\\s*" );
  
  String[] split = pattern.split(fields);
  for (String string : split) {
      System.out.println(string);
  }
  </code></pre>
  
  <p>What am I doing wrong here?</p>
  
  <p>Thank you</p>