title: Regexp even number of backslashes (PHP)
body: <p>I have rather hard time getting my head around regular expression, especially more complex formulas.</p>
  <p>Currently I am writing my own markup language and am stumped by escaping. I want each special character to be &quot;escapable&quot;, that is if <code>*bold*</code> would give me <code>&lt;b&gt;bold&lt;/b&gt;</code>, then <code>\*bold\*</code> should leave it as-is, so I can do the stripping of backslashes later, but I can't think of a regular expression to convey this idea.<br />
  How can I select three groups:</p>
  <ol>
  <li>Left asterisk if the number or BSes preceding it is even;</li>
  <li>Content between asterisks;</li>
  <li>Right asterisk if the number of BSes preceding it is even;</li>
  </ol>
  <p>with one regular expression? I need it to be compliant with PHP's <code>preg_replace</code>.</p>
  <p>This <code>\\*(\*)\S(.)+?\S\\*(\*)</code> would select both asterisks and content as three groups, but that doesn't check for 'evenity' and stuff.</p>
  <h1>UPDATE:</h1>
  <p>The second paragraph has been changed to better illustrate what I meant (please don't modify it anymore because the change that was made completely missed the point).</p>
  <p>Plus, if that makes things easier, I can first parse any double backslash into some other character, so there is only need to check for ONE backslash before asterisk.</p>