Regex to capture string inside single or double quotation marks
<p>I am writing a regular expression to parse lines containing labeled fields. The label appears before an equals sign, and the content appears after the equalts sign, enclosed in either single or double quotation marks. For most fields, the content is enclosed in single quotation marks. If the content of the field contains single quotation marks, then the field is enclosed in double quotation marks. E.g.:</p>

<pre><code>J=''K='6'2='A'6='&amp;JOBNAM#'P='&amp;USERNAME#'O='1,1'7=''Q='ABC.JCLLIB(TEST1)'a="'D08/APPL'"U='1'S='*ALL'T='0'V='0'R='H'W='H'
</code></pre>

<p>My regex works, except with fields enclosed in double quotation marks.</p>

<pre><code>([JK26PO7QaUSTVRW])\=(?:(?:\"([^"])*\")|(?:\'([^']*)\'))
</code></pre>

<p><a href="https://www.debuggex.com/r/eJKwl0E1yrXnrA9X" rel="nofollow">Test in Debuggex</a></p>

<p><a href="http://regexr.com/3easb" rel="nofollow">Test in Regexr</a></p>

<p>For fields like the one labeled <em>a</em> in the example above, <em>a="'D08/APPL'"</em>, the a is matched by capture group 1, and the trailing single quotation mark is captured by capture group 2. I want capture group 2 to capture <em>'D08/APPL'</em> in this case.</p>