package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?<=twitch.tv\s)\w+(?=\s#)`)
var str = `@badges=moderator/1,premium/1;color=#00FF80;display-name=gempir;emotes=;id=d0358df2-f0a1-4600-910e-515ec52b1baa;mod=1;room-id=99659894;sent-ts=1489250823035;subscriber=0;tmi-sent-ts=1489250823211;turbo=0;user-id=77829817;user-type=mod :gempir!gempir@gempir.tmi.twitch.tv PRIVMSG #gempbot :!status
@ban-duration=20;ban-reason=Banned\slink;room-id=11148817;target-user-id=78424343 :tmi.twitch.tv CLEARCHAT`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Golang, please visit: https://golang.org/pkg/regexp/