Regex for double quotes inside string
<p>A follow up to my previous question <a href="https://stackoverflow.com/questions/36838311/match-two-quotes-not-preceded-by-opening-bracket">here</a>. I realize I need to be more specific regarding my regex case to get an answer that works for my case.</p>

<p>I am fighting with this regex already for quite some time (also using the answers from my previous question) and I seem to be unable to build what I need. </p>

<p>I need to replace all occurrences of two recurring single quotes <code>''</code> with <code>\'</code> inside all strings (so inside strings means between single quotes <code>'somesStringWithOrWithoutDoubleQuoteOccurrences'</code>).
It is because in one language (syntax) quotes within the string are escaped with a <code>'</code> while the other (javascript) uses <code>\</code> for escaping.</p>

<p>Here an example (the actual example can contains multiple strings separated with <code>,</code> but <code>,</code> can of course also appear withing the strings):</p>

<pre><code>'word'''',and''','another'',''word','''test',X,'',FUNCTION('A'' B C D')
"--------------","----------------","------",-,"",FUNCTION("---------")
"    ++++    ++","       ++ ++    ","++    ", ,"",        (" ++      ")
     1 2     3           4  5        6                       7
</code></pre>

<p>result after <code>replace</code> should be:</p>

<pre><code>'word\'\',and\'','another\',\'word','\'test',X,'',FUNCTION('A\' B C D')
</code></pre>

<p><code>++</code> is a required match the opening and closing quote in the string (represented by <code>"</code>) in line below the example should never be part of match (these single quotes mark the actual beginning or end of the string in which double quotes can appear).</p>

<p>It seems so simple when I see it, I can point out the double quotes immediately from the string but I am unable to get it properly defined inside my pattern.</p>

<hr>

<h2>Alternative</h2>

<p>Another solution could be to replace the opening and closing quote with double quotes and replace the double occurrence of the single quite with a single single quote:</p>

<pre><code>'word'''',and''','another'',''word','''test',X,'',FUNCTION('A'' B C D')
"--------------","----------------","------",-,"",FUNCTION("---------")
     ++++    ++ ,        ++ ++     , ++     , ,  ,        (  ++       )
     1 2     3           4  5        6                       7
</code></pre>

<p>result after <code>replace</code> in this case would be:</p>

<pre><code>"word'',and'","another','word","'test",X,"",FUNCTION("A' B C D")
</code></pre>

<hr>

<p><strong><a href="https://jsfiddle.net/ozy8syas/" rel="nofollow noreferrer">Here is a prepared Fiddle to test patterns</a></strong></p>

<p>For what it helps I came up with not working: </p>

<pre><code>/'(('{2})+)*'/g
</code></pre>

<p>and</p>

<pre><code>/'[^']*(('')*)*[^']*'/g
</code></pre>

<p>and</p>

<pre><code>/('(('{2})*)*')[^,$]/g
</code></pre>