title: Parsing CSV with a RegEx in java - escape double quote within cell
body: <p>I am looking for a java regex which will escape the doublequote within an excel cell.</p>
  
  <p>I have followed this example but need another change in the regular expression to make it work for escaping doublequote within one of the cells.</p>
  
  <p><a href="https://stackoverflow.com/questions/1441556/parsing-csv-input-with-a-regex-in-java">Parsing CSV input with a RegEx in java</a></p>
  
  <pre><code>private final Pattern pattern = Pattern.compile("\"([^\"]*)\"|(?&lt;=,|^)([^,]*)(?=,|$)");
  </code></pre>
  
  <p>Example Data:</p>
  
  <blockquote>
    <p>"A,B"<strong><em>,</em></strong>"2" size"<strong><em>,</em></strong>"text1,text2, text3"</p>
  </blockquote>
  
  <p>The regex from above fails at <code>2"</code>. </p>
  
  <p>I want the output to be as below .Doesn't matter if the outer double quotes are there or not.</p>
  
  <p>"A,B"<br>
  "2" size"<br>
  "text1,text2, text3"</p>