title: Regular expression to extract hashtags excluding the ones from anchor tags
body: <p>I need to extract #tags from the text editor except for the ones inside anchor tags. The expression I am using currently is:
  (^|\s)(#[a-z\d-_]+) </p>
  
  <p>This works fine and shows all matches correctly in the test websites like
  <a href="https://regex101.com/r/pJ4wC5/57" rel="nofollow">https://regex101.com/r/pJ4wC5/57</a>. However when i plugin the same expression its not identifying the ones which are at the beginning of the string.</p>
  
  <p>Edit:
  this is the code</p>
  
  <pre><code>text=newText.replace(/(?!&lt;a[^&gt;]*?&gt;)(^|\s)(#[a-z\d-_]+)(?![^&lt;]*?&lt;\/a&gt;)/img,function (match,index) {
  if(newText[index-1]!=='&amp;'){ 
  return '&lt;a  href="" data-hashfilter&gt;' + match + '&lt;/a&gt;'
  }else{
  return match
    }
  });
  </code></pre>
  
  <p>I need to capture hash tags preceding with space or start of the string</p>