package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(?<Name>\b\S*?):\s(?<Value>.*?)\s*(?=(?:\b\S*?:\s)|$)`)
var str = `REKVISITION_NR: 1234567 Dato: 23-07-2018 Rekvirent: ABC, DEF GHI, JKL 60, 8600 MNO Sted: JKL 60, 8600 MNO, Kl.:14:00:00, Bestilt_tid: 60 min Tolkensnavn: PQR STU Koert_fra: VXY , 8600 Silkeborg Vedr.: Z CPR: 123456-7890 Sprog: Arabisk Type: Personlig fremmøde Godkendt: 24-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/