package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`\(PERMBLOCK\)\s(?<IP>[.0-9]*)\s\((?<country>.{2}).*? - (?<date>.*)`)
var str = `180.76.15.158 # lfd: (PERMBLOCK) 180.76.15.158 (CN/China/baiduspider-180-76-15-158.crawl.baidu.com) has had more than 4 temp blocks in the last 86400 secs - Mon Jun 11 05:20:35 2018
80.211.140.69 # lfd: (PERMBLOCK) 80.211.140.69 (IT/Italy/host69-140-211-80.serverdedicati.aruba.it) has had more than 4 temp blocks in the last 86400 secs - Mon Jun 11 05:39:16 2018
94.65.235.31 # lfd: (PERMBLOCK) 94.65.235.31 (GR/Greece/ppp-94-65-235-31.home.otenet.gr) has had more than 4 temp blocks in the last 86400 secs - Mon Jun 11 18:40:52 2018
94.71.194.156 # lfd: (PERMBLOCK) 94.71.194.156 (GR/Greece/athedsl-4511380.home.otenet.gr) has had more than 4 temp blocks in the last 86400 secs - Tue Jun 12 02:24:44 2018
114.207.112.188 # lfd: (PERMBLOCK) 114.207.112.188 (KR/Republic of Korea/114-207-112-188.tongkni.co.kr) has had more than 4 temp blocks in the last 86400 secs - Tue Jun 12 12:12:10 2018
94.64.71.183 # lfd: (PERMBLOCK) 94.64.71.183 (GR/Greece/ppp-94-64-71-183.home.otenet.gr) has had more than 4 temp blocks in the last 86400 secs - Wed Jun 13 03:54:37 2018
89.210.18.91 # lfd: (PERMBLOCK) 89.210.18.91 (GR/Greece/ppp089210018091.access.hol.gr) has had more than 4 temp blocks in the last 86400 secs - Wed Jun 13 04:07:48 2018
94.65.149.72 # lfd: (PERMBLOCK) 94.65.149.72 (GR/Greece/ppp-94-65-149-72.home.otenet.gr) has had more than 4 temp blocks in the last 86400 secs - Fri Jun 15 05:22:46 2018
94.64.70.87 # lfd: (PERMBLOCK) 94.64.70.87 (GR/Greece/ppp-94-64-70-87.home.otenet.gr) has had more than 4 temp blocks in the last 86400 secs - Sun Jun 17 07:06:11 2018
94.64.66.189 # lfd: (PERMBLOCK) 94.64.66.189 (GR/Greece/ppp-94-64-66-189.home.otenet.gr) has had more than 4 temp blocks in the last 86400 secs - Mon Jun 18 00:28:35 2018
180.76.15.6 # lfd: (PERMBLOCK) 180.76.15.6 (CN/China/baiduspider-180-76-15-6.crawl.baidu.com) has had more than 4 temp blocks in the last 86400 secs - Tue Jun 19 22:15:29 2018
94.65.145.144 # lfd: (PERMBLOCK) 94.65.145.144 (GR/Greece/ppp-94-65-145-144.home.otenet.gr) has had more than 4 temp blocks in the last 86400 secs - Wed Jun 20 01:13:08 2018
180.76.15.145 # lfd: (PERMBLOCK) 180.76.15.145 (CN/China/baiduspider-180-76-15-145.crawl.baidu.com) has had more than 4 temp blocks in the last 86400 secs - Thu Jun 21 13:55:36 2018
2.84.214.95 # lfd: (PERMBLOCK) 2.84.214.95 (GR/Greece/ppp-2-84-214-95.home.otenet.gr) has had more than 4 temp blocks in the last 86400 secs - Thu Jun 21 20:39:07 2018`
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/