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:
\b(?<![@#\/])\w.*
So with the input:
/msg @nickname #channel foo bar baz
/foo #channel @nickname foo bar baz
foo bar baz
foo bar baz
is extracted every time. See working example
https://regex101.com/r/lF9aG7/3
In Go however this doesn't compile http://play.golang.org/p/gkkVZgScS_
It throws:
panic: regexp: Compile(`\b(?<![@#\/])\w.*`): error parsing regexp: invalid or unsupported Perl syntax: `(?<`
I did a bit of research and realized negative lookbehinds are not supported in the language to guarantee O(n) time.
How can I rewrite this regex so that it does the same without negative lookbehind?
(?:^|[^@#/])\b(\w.*)
? – Mariano[#@/]
. – hjpotter92