title: Nested regex lookahead and lookbehind
body: <p>I am having problems with the nested '+'/'-' lookahead/lookbehind in regex.</p>
  
  <p>Let's say that I want to change the <code>'*'</code> in a string with <code>'%'</code> and let's say that <code>'\'</code> escapes the next character. (Turning a regex to sql like command ^^). </p>
  
  <p>So the string </p>
  
  <ul>
  <li><code>'*test*'</code> should be changed to <code>'%test%'</code>, </li>
  <li><code>'\\*test\\*'</code> -> <code>'\\%test\\%'</code>, but </li>
  <li><code>'\*test\*'</code> and <code>'\\\*test\\\*'</code> should stay the same.</li>
  </ul>
  
  <p>I tried:</p>
  
  <pre><code>(?&lt;!\\)(?=\\\\)*\*      but this doesn't work
  (?&lt;!\\)((?=\\\\)*\*)    ...
  (?&lt;!\\(?=\\\\)*)\*      ...
  (?=(?&lt;!\\)(?=\\\\)*)\*  ...
  </code></pre>
  
  <p>What is the correct regex that will match the '*'s in examples given above?</p>
  
  <p>What is the difference between <code>(?&lt;!\\(?=\\\\)*)\*</code> and <code>(?=(?&lt;!\\)(?=\\\\)*)\*</code> or if these are essentially wrong the difference between regex that have such a visual construction?</p>