package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?sm)^(Sensor #0 -> (?P<EXT>\d+[.]\d+)(?:.*?Sensor #2 -> )(?P<INT>\d+[.]\d+)(?:.*?)(?P<DATE>\d{4}\/\d{2}\/\d{2}\s+\d{2}:\d{2}:\d{2}))`)
var str = `system tmp gettemp 0
Sensor #0 -> 69.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 87.81
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:50system tmp gettemp 0
Sensor #0 -> 69.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 88.110
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:51system tmp gettemp 0
Sensor #0 -> 69.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 88.206
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:52system tmp gettemp 0
Sensor #0 -> 69.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 87.176
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:53system tmp gettemp 0
Sensor #0 -> 69.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 88.110
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:54system tmp gettemp 0
Sensor #0 -> 69.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 88.110
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:55system tmp gettemp 0
Sensor #0 -> 69.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 87.176
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:56system tmp gettemp 0
Sensor #0 -> 69.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 87.81
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:57system tmp gettemp 0
Sensor #0 -> 68.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 88.15
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:58system tmp gettemp 0
Sensor #0 -> 68.0
OK
dbg_cpu0> system tmp gettemp 2
Sensor #2 -> 88.15
OK
dbg_cpu0>
dbg_cpu0> 2016/11/23 11:04:59system tmp gettemp 0
Sensor #0 -> 68.0
OK
dbg_cpu0> 2016/11/23 11:05:002016/11/23 11:05:012016/11/23`
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/