title: How to simulate negative lookbehind in Go
body: <p>I'm trying to write a regex that can extract a command, here's what I've got so far using a negative lookbehind assertion:</p>
  
  
  
  <pre class="lang-none prettyprint-override"><code>\b(?&lt;![@#\/])\w.*
  </code></pre>
  
  <p>So with the input:</p>
  
  <pre class="lang-none prettyprint-override"><code>/msg @nickname #channel foo bar baz
  /foo #channel @nickname foo bar baz 
  foo bar baz
  </code></pre>
  
  <p><code>foo bar baz</code> is extracted every time. See working example 
  <a href="https://regex101.com/r/lF9aG7/3" rel="noreferrer">https://regex101.com/r/lF9aG7/3</a></p>
  
  <p>In Go however this doesn't compile <a href="http://play.golang.org/p/gkkVZgScS_" rel="noreferrer">http://play.golang.org/p/gkkVZgScS_</a></p>
  
  <p>It throws:</p>
  
  <pre class="lang-none prettyprint-override"><code>panic: regexp: Compile(`\b(?&lt;![@#\/])\w.*`): error parsing regexp: invalid or unsupported Perl syntax: `(?&lt;`
  </code></pre>
  
  <p>I did a bit of research and realized negative lookbehinds are not supported in the language to guarantee O(n) time.</p>
  
  <p>How can I rewrite this regex so that it does the same without negative lookbehind?</p>