title: Regex to match URLs and exclude those in <a> and <img> tag
body: <p>I'm trying to match URLs but excluding those within <code>&lt;a&gt;</code> and <code>&lt;img&gt;</code> tags.</p>
  <p><code>/(?!(?!.&lt;a)[^&lt;].*&lt;\/a&gt;)([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&amp;:/~+#-]*[\w@?^=%&amp;/~+#-])?/ig</code></p>
  <p>The problem is that it match the url within <code>&lt;img&gt;</code> if it's not in <code>&lt;a&gt;</code> tag</p>
  <p>For example:</p>
  <ol>
  <li><code>&lt;a href=&quot;https://google.com&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;Google&lt;/a&gt;</code> <strong>NOT MATCH (Correct)</strong></li>
  <li>google.com <strong>MATCH (Correct)</strong></li>
  <li><code>&lt;a href=&quot;google.com&quot; rel=&quot;noopener noreferrer&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png&quot;&gt;&lt;/a&gt;</code> <strong>NOT MATCH (Correct)</strong></li>
  <li><code>&lt;p&gt;https://google.com&lt;/p&gt;</code> <strong>MATCH (Correct)</strong></li>
  <li><code>&lt;img src=&quot;https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png&quot;&gt;</code> <strong>MATCH (WRONG)</strong></li>
  </ol>
  <p>What should I add o remove to my Regex?</p>