<?xml version="1.0" encoding="windows-1252"?>
<node id="992915" title="Re^4: Problem with alternating regex?" created="2012-09-11 00:21:50" updated="2012-09-11 00:21:50">
<type id="11">
note</type>
<author id="461912">
GrandFather</author>
<data>
<field name="doctext">
&lt;blockquote&gt;&lt;i&gt;
&lt;blockquote&gt;
&lt;i&gt;The double quote pairing is in fact correct&lt;/i&gt;
&lt;/blockquote&gt;

&lt;code&gt;
# /^set\szone\s("([^"]*)"|id\s\d+\s"([^"]*)")/
#              ^       ^            ^     ^
&lt;/code&gt;

&lt;p&gt;Yes, it is actually the &lt;i&gt;first&lt;/i&gt; format which has the right parenthesis in the wrong place. But, as you say, that wasn&amp;rsquo;t the OP&amp;rsquo;s problem either.&lt;/p&gt;
&lt;/i&gt;&lt;/blockquote&gt;
&lt;p&gt;No. The OP's parenthesis matching really is correct - all of it. The parenthesis pairing is:&lt;/p&gt;
&lt;c&gt;
#              v                            v
# /^set\szone\s("([^"]*)"|id\s\d+\s"([^"]*)")/
#                ^     ^            ^     ^
&lt;/c&gt;
&lt;p&gt;The OP's issue is that the parenthesis marked with 'v' are the $1 capture group. The two sets of parenthesis marked with ^ are what the OP hoped were $1, but really they are redundant grouping parenthesis.&lt;/p&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-461912"&gt;
True laziness is hard work
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
992899</field>
<field name="parent_node">
992910</field>
</data>
</node>
