title: Regex to match anything except HTML tags when code is encoded using &lt; and &gt;
body: <p>I am trying to use regex to match any text except for HTML tags. I have found this solution for &quot;normal&quot; HTML code:</p>
  <pre><code>&lt;[^&gt;]*&gt;(*SKIP)(*F)|[^&lt;]+
  </code></pre>
  <p>However, my code is encoded using <code>&amp;lt;</code> and <code>&amp;gt;</code> instead of <code>&lt;</code> and <code>&gt;</code>, and I have not been able to modify the regex above for it to work.</p>
  <p>As an example, given the text:</p>
  <p><code>Hi &amp;lt;p class=\&quot;hello\&quot;&amp;gt;\r\nthere, how are you\r\n&amp;lt;/p&amp;gt;</code></p>
  <p>I need to match &quot;hi&quot; and &quot;there, how are you&quot;. Note that I need to match text that is not between tags as well, &quot;hi&quot;, in this example.</p>
  <p>UPDATE: since I am using ruby's gsub, it looks like I cannot even use *SKIP and *F</p>
  <p>UPDATE 2:  I was trying not to get into much detail but seems to be important:
  I actually need to replace all the spaces from a text, but not those spaces that are part of a tag, be it a <code>&amp;lt; ... &amp;gt;</code> tag or a <code>&lt;...&gt;</code> tag.</p>