title: java-Match a regex pattern in a string(listing matching and non-matching parts)
body: <p>i have a csv string containing five fields(3 mandatory and 2 optional). The optional fields are in posiition 3 and 5.
  I have a regex pattern to identify the strings in double quotes</p>
  
  <pre><code>    private static final String TEXT_IN_DBL_QUOTES_REGEX="\"([^\"]*)\"";
      private static final String rowData="\"Field1\", \"Field2\", , \"Field4\", ";
  
      public static void main(String[] args){
          List&lt;String&gt; fields = Lists.newArrayList();
          Pattern regex = Pattern.compile(TEXT_IN_DBL_QUOTES_REGEX);
          Matcher matcher = regex.matcher(rowData);
          while(matcher.find()){
             fields.add(matcher.group(1));
          }
          return fields;
      }
  
  My expected result is an array list containing 
  Field1, Field2, null, Field4, null
  but the above is returning 
  Field1, Field2, Field4
  </code></pre>
  
  <p>How can i tweak the above code to get the desired result?</p>