package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`\[([^\].]*)\]:\W?(.*)`)
var str = `[12:17:05][econ]: cid=0 authed
[12:17:11][server]: player is ready. ClientID=0 addr=87.100.133.110:64762
[12:17:11][game]: Teams are balanced (red=1 blue=0)
[12:17:11][server]: player has entered the game. ClientID=0 addr=87.100.133.110:64762
[12:17:11][game]: team_join player='0:wavi' team=0
[12:17:13][game]: pickup player='0:wavi' item=3
[12:17:25][game]: pickup player='0:wavi' item=2
[12:17:33][game]: flag_grab player='0:wavi' team=0
[12:17:34][game]: pickup player='0:wavi' item=1
[12:17:34][game]: pickup player='0:wavi' item=1
[12:17:43][game]: pickup player='0:wavi' item=0
[12:17:44][game]: flag_capture player='0:wavi' team=0 time=11.38
[12:17:48][game]: kill killer='0:0:wavi' victim='0:0:wavi' weapon=-1 special=0
[12:17:52][server]: client dropped. cid=0 addr=87.100.133.110:64762 reason=''
[12:17:52][game]: kill killer='0:0:wavi' victim='0:0:wavi' weapon=-3 special=0
[12:17:52][game]: leave player='0:wavi'
[12:17:52][game]: Teams are balanced (red=0 blue=0)
[econ]: cid=0 authed
[server]: player is ready. ClientID=0 addr=87.100.133.110:64762
[game]: Teams are balanced (red=1 blue=0)
[server]: player has entered the game. ClientID=0 addr=87.100.133.110:64762
[game]: team_join player='0:wavi' team=0
[game]: pickup player='0:wavi' item=1
[game]: pickup player='0:wavi' item=1
[game]: pickup player='0:wavi' item=1
[game]: pickup player='0:wavi' item=2
[game]: pickup player='0:wavi' item=4
[game]: flag_grab player='0:wavi'
[game]: pickup player='0:wavi' item=2
[game]: pickup player='0:wavi' item=0
[game]: pickup player='0:wavi' item=3
[game]: flag_capture player='0:wavi'
[game]: pickup player='0:wavi' item=2
[game]: kill killer='0:wavi' victim='0:wavi' weapon=-1 special=0
[server]: client dropped. cid=0 addr=87.100.133.110:64762 reason=''
[game]: leave player='0:wavi'
[game]: Teams are balanced (red=0 blue=0)`
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/