title: Splitting on comma outside quotes when escaped quotes exist
body: <p>Is there any way to split commas outside quotes, and ignore double single quotes within the quotes? This would be really useful when manipulating with SQL.</p>
  
  <p>I'm trying to split SQL statements, and SQL uses single quote to escape single quote within strings.</p>
  
  <p>e.g. </p>
  
  <pre><code>String source = "ADDRESS.CITY || ', UK''s', ADDRESS.CITY || ', US''s', ADDRESS.CITY || ', UK''s'";
  
  String[] expected = new String[]{
  "ADDRESS.CITY || ', UK''s'", 
  "ADDRESS.CITY || ', US''s'",
  "ADDRESS.CITY || ', UK''s'"
  };
  
  String[] result = splitElements(source);
  assert expected.equals(result);
  </code></pre>
  
  <p>I have tried <a href="https://stackoverflow.com/questions/18893390/splitting-on-comma-outside-quotes">Splitting on comma outside quotes</a> and changed it to single quotes i.e. </p>
  
  <pre><code>source.split(",(?=(?:[^\']*\'[^\']*\')*[^\']*$)")
  </code></pre>
  
  <p>The problem is it doesn't ignore double single quotes.</p>
  
  <p>I have also tried to combine it with  <a href="https://stackoverflow.com/questions/3735841/split-with-single-colon-but-not-double-colon-using-regex">Split with single colon but not double colon using regex</a>, but wouldn't be able to get it working so far.</p>