package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?mi)^(AN|AA|AD|AE).*?(Jan|Feb|Mar|Apr|May|Jun|JUL|Aug|Sep|Oct|Nov|Dec)*([a-z]{3})([a-z]{3})|^FXD.*?([a-z]{3})([ ]*\/[ ]*[d,D]\d\d\w\w\w|[ ]*\/[ ]*[t,T][d,D]\d\d\d\d)*([a-z]{3})*([ ]*\/[ ]*[d,D]\d\d\w\w\w|[ ]*\/[ ]*[t,T][d,D]\d\d\d\d)*([a-z]{3})*`)
var str = `fxdbom /d12augdel
FXD 4 JFKMIA
FXDJFK/ D15JUNMIA /D25JUNATL/D27JUNJFK
FXDJFK/D15JUN/TD0900MIA
FXD 2 PAR /D15JUNMIA //PB2500
FXD BOM /D12AUGDEL /D23SEPBOM
FXD BOM /D23AUGDEL /D24SEPBOM`
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/