package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^[LNSE] .*(?:\n(?![LNSE] ).*)?`)
var str = `L 065 00 24329 12313 244.0.15.55 252.9.11.90 02/25 08:05 00:00:44 0000 0000
N 066 00 23442 T000185 262.1.00.09 02/25 08:05 00:00:02 A 16630
& 0000 0000
S 067 00 00984 T000134 02/25 08:06 00:00:02 A 61445
& 0000 0000
S 068 00 T000002 29536 02/25 08:05 00:00:36
& 0000 0000 1234567890XXXXXX
E 069 00 T000002 T000185 02/25 08:06 00:00:00
& 0000 0000 1234567890XXXXXX
L 065 00 24329 12313 244.0.15.55 252.9.11.90 02/25 08:05 00:00:44 0000 0000 `
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/