<p>I have this .NET regex:</p>

<pre><code>^(?&lt;prefix&gt;("[^"]*"))\s(?&lt;attrgroup&gt;(\([^\)]*\)))\s(?&lt;suffix&gt;("[^"]*"))$
</code></pre>

<p>It properly matches the following strings:</p>

<pre><code>"some prefix" ("attribute 1" "value 1") "some suffix"
"some prefix" ("attribute 1" "value 1" "attribute 2" "value 2") "some suffix"
</code></pre>

<p>It fails on...</p>

<pre><code>"some prefix" ("attribute 1" "value (fail) 1") "some suffix"
</code></pre>

<p>...due to the right paren after "fail".</p>

<p>How can I modify my regex so that the <code>attrgroup</code> match group will end up containing "<code>("attribute 1" "value (fail) 1")</code>"? I've been looking at it for too long and need some fresh eyes. Thanks!</p>

<p><strong>Edit:</strong> <code>attrgroup</code> won't ever contain anything other than pairs of double-quoted strings.</p>

```
```
^(?<prefix>"[^"]*")\s+(?<attrgroup>\(.*\))\s+(?<suffix>"[^"]*")$
```
```
fixed it for me.
I removed the extraneous unnamed groups and simplified (down to "any character") the attribute group.
A
very
worthwhile investment would be JG Soft's RegexBuddy
Edit: This won't validate the attribute group as pairs of quoted strings, but that should/could be done in a separate regex/validation step.