title: RegEx: Look-behind to avoid odd number of consecutive backslashes
body: <p>I have user input where some tags are allowed inside square brackets. I've already wrote the regex pattern to find and validate what's inside the brackets.</p>
  
  <p>In user input field opening-bracket could ([) be escaped with backslash, also backslash could be escaped with another backslash (\). I need look-behind sub-pattern to avoid odd number of consecutive backslashes before opening-bracket.</p>
  
  <p>At the moment I must deal with something like this:</p>
  
  <pre><code>(?&lt;!\\)(?:\\\\)*\[(?&lt;inside brackets&gt;.*?)]
  </code></pre>
  
  <p>It works fine, but problem is that this code still matches possible pairs of consecutive backslashes in front of brackets (even they are hidden) and look-behind just checks out if there's another single backslash appended to pairs (or directly to opening-bracket). I need to avoid them all inside look-behind group if possible.</p>
  
  <h2>Example:</h2>
  
  <pre><code>my [test] string is ok
  my \[test] string is wrong
  my \\[test] string is ok
  my \\\[test] string is wrong
  my \\\\[test] string is ok
  my \\\\\[test] string is wrong
  ...
  etc
  </code></pre>
  
  <p>I work with PHP PCRE</p>