package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`^(.*?)/(.*?),now\s(.*?)\s(.*?)\s`)
var str = `usbmuxd/kali-rolling,now 1.1.0-2+b1 amd64 [installed,automatic]
usbutils/kali-rolling,now 1:007-4 amd64 [installed]
util-linux/kali-rolling,now 2.28-6 amd64 [installed]
uuid-runtime/kali-rolling,now 2.28-6 amd64 [installed,automatic]
va-driver-all/kali-rolling,now 1.7.1-2 amd64 [installed,automatic]
vboot-kernel-utils/kali-rolling,now 0~R52-8350.B-1 amd64 [installed,automatic]
vboot-utils/kali-rolling,now 0~R52-8350.B-1 amd64 [installed,automatic]
vdpau-driver-all/kali-rolling,now 1.1.1-3 amd64 [installed,automatic]
`
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/