title: regex: negative lookbehind in negation character class? (.NET flavour)
body: <p>What I'm trying to do: remove innermost unescaped square brackets surrounding a specific, unescaped character (<code>\</code> is escape)</p>
  
  <p>input: <code>[\[x\]]\]\[[\[y\]]</code><br>
  output when looking for brackets around y: <code>[\[x\]]\]\[\[y\]</code><br>
  output when looking for brackets around x: <code>\[x\]\]\[[\[y\]]</code></p>
  
  <p>In short, remove only the unescaped set of brackets around the specific character.</p>
  
  <p>I tried this (for y): <code>Regex.Replace(input, @"(?&lt;!\\)\[(.*?(?&lt;!\\)y.*?)(?&lt;!\\)\]",@"$1"</code>, but that seems to match the first unescaped <code>[</code> (before the x) with the last <code>]</code>. I figured I could replace the <code>.</code> wildcards with a negating character class to exclude <code>[</code> and <code>]</code>, but what I really need to negate is <em>unescaped</em> versions of these, and when I try to incorporate a negative lookbehind like <code>(?&lt;!\\)</code> in the negating character class, I seem to match nothing at all.</p>
  
  <p>Thanks in advance for your time and effort.</p>
  
  <h3>edit:</h3>
  
  <p>To clarify, the contents of the unescaped square brackets can be anything (except another unescaped square bracket), as long as they contain the unescaped character of interest (<code>y</code>). All the content of the brackets should remain.</p>