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:
(?<![@#/])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(`(?<![@#/])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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…