title: Regexp matching for text outside html tags in MySQL
body: <p>I have a sql query in MySQL and I want an expression that matches with the string not between '&lt;' and '>'. For example:</p>
  
  <pre><code>select '&lt;span class="boldtext"&gt;collaboratively site&lt;/span&gt; – regardless of platform or language' rlike 'expression looking for boldtext' ==&gt; should return false because 'boldtext' locates inside a html tag
  select '&lt;span class="boldtext"&gt;collaboratively site&lt;/span&gt; – regardless of platform or language' rlike 'expression looking for platform' ==&gt; should return true because 'platform' locates outside a html tag
  </code></pre>
  
  <p>I tried with below but no luck. I guess because the '*' is greedy. </p>
  
  <pre><code>select '...' rlike '[^[.&lt;.]]?[^[.&gt;.]]*platform[^[.&lt;.]]*[^[.&gt;.]]?' # This expression doesn't work
  </code></pre>
  
  <p>I knew that the expression would be like below if it's run on a programming language like Ruby or PHP</p>
  
  <pre><code>'&lt;span class="boldtext"&gt;collaboratively site&lt;/span&gt; – regardless of platform or language' =~ /((?!&lt;[^&gt;]*))\bboldtext\1/ # =&gt; false
  '&lt;span class="boldtext"&gt;collaboratively site&lt;/span&gt; – regardless of platform or language' =~ /((?!&lt;[^&gt;]*))\bplatform\1/ # =&gt; true
  </code></pre>
  
  <p>I found a <a href="https://stackoverflow.com/questions/1224723/need-regexp-matching-in-mysql">similar post</a> but I can't rewrite it for my case.</p>
  
  <p>Could you help me how to come up with the expression that matches string not inside html tag purpose (run in mysql rlike operator) ?</p>