package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^([^,\n]*,){3}([^,]+)`)
var str = `+000000006 06:23:15.291450,W-CHEVLPFULL-LP | ,+000000006 06:23:15.291450,W-CHEVUS | ,
+000000044 08:09:52.291450,W-ADITIVOSSM-SM | KM8014,+000000044 08:09:52.291450,W-CHEVLPFULL-LP | KM8014,
+000000125 00:53:18.291450,W-ADITHPSMFULL-HP-SM | ,+000000125 00:53:18.291450,W-ADITIVOSSM-SM | ,
+000000138 05:08:01.291450,W-ADITHPSMFULL-HP-SM | KM8512,+000000138 05:08:01.291450,W-EMPTYAVAILABLE | KM8512,
+000000138 05:20:45.291450,W-ADITIVOSSM-SM | ,+000000138 05:20:45.291450,W-EMPTYAVAILABLE |`
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/