title: Regex to validate hashtags (#) ignoring URLs that contain anchor (#)
body: <p>I have any type of text entries:</p>
  
  <pre><code>#teste
  
  #teste:
  
  ##teste
  
  oi esse é um tempo com #blalbalb no meio da #gxD
  
  https://g1.globo.com/economia/noticia/2019/09/16/precos-do-#petroleo-disparam-apos-ataques-a-instalacoes-na-arabia-saudita.ghtml
  
  http://nexus.dfdff.com/-#browse:central
  
  http://nexus.ssdff.com/#browse/browse:npm-group
  
  https://mail.google.com/mail/u/0/#inbox
  
  </code></pre>
  
  <p>I need to identify only texts that contain <code>#</code>. The difficulty is that URLs might also contain <code>#</code>.</p>
  
  <p>My regular expression so far: <a href="https://regex101.com/r/LLHo0w/3" rel="nofollow noreferrer">https://regex101.com/r/LLHo0w/3</a></p>
  
  <p><code>\B(\#[a-zA-Z]+\b)(?!\/|\-|\:)</code></p>
  
  <p>Wrong match: <a href="https://mail.google.com/mail/u/0/" rel="nofollow noreferrer">https://mail.google.com/mail/u/0/</a><strong>#inbox</strong> some text <strong>#hi</strong></p>
  
  <p>Correct match: <a href="https://mail.google.com/mail/u/0/#inbox" rel="nofollow noreferrer">https://mail.google.com/mail/u/0/#inbox</a> some text <strong>#hi</strong></p>
  
  <pre><code>\B(\#[a-zA-Z]+\b)(?!\/|\-|\:)
  
  var html = "&lt;a href="#" data-timeline-action="search"&gt;$1&lt;/a&gt;"
  var text= "vamos ser #amigos pode ser? https://mail.google.com/mail/u/0/#inbox"
  text.replace(/\B(\#[a-zA-Z]+\b)(?!\/|\-|\:)/ig, html);
  </code></pre>