title: Regex - Match emoticon :P but ignore when inside <code></code> tags
body: <p>I'm developing a Smarty modifier that allows me to use emoticons in addition to several other things. Everything is fine but I've never been so good with regex so I need help. This is my string:</p>
  
  <pre><code>:P &lt;code&gt;:P : P hello : P&lt;/code&gt; :P [sub]ssss[/sub]&lt;b&gt;:P&lt;/b&gt; : P
  </code></pre>
  
  <p>I'm replacing <strong>:P</strong> with the "smile" emoticon that we all know but the problem is that I do not want to replace <strong>:P</strong> with my "smile" inside code tags:</p>
  
  <pre><code>&lt;code&gt;&lt;/code&gt;
  </code></pre>
  
  <p>In other words everything inside the above tag should be ignored. The replacement should work only for all the <strong>:P</strong> outside. Until now this is what I managed to achieve:</p>
  
  <pre><code>\&lt;code\&gt;(^(.*?))\&lt;\/code\&gt;|:P
  </code></pre>
  
  <p>But it only matches the first <strong>:P</strong> then stops when code tag starts. Let me make it even more clear.</p>
  
  <pre><code>:P &lt;code&gt;:P : P hello : P&lt;/code&gt; :P [sub]ssss[/sub]&lt;b&gt;:P&lt;/b&gt; : P
  </code></pre>
  
  <p>I have to match the first <strong>:P</strong>, not the second inside code, the third between the code closing tag and [sub] is valid and the one inside b tags too.</p>
  
  <p>Thank you.</p>