package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`car (zap(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|yes(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|xerox(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|with(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|view(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|under(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|this(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|sort(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|rest(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|quick|(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|orange(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|nope|(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|letter(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|kayak(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|joseph(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|indiana(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|humus(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|gelatin(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|frankfurter(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|elephant(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|doormat(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|carrot(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|banana(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?|apple(?: zap| yes| xerox| with| view| under| this| sort| rest| quick| pie| orange| nope| meal| letter| kayak| joseph| indiana| humus| gelatin| frankfurter| elephant| doormat| carrot| banana| apple)?) crashed`)
var str = `car apple view crashed
car doormat elephant crashed
car humus zap crashed
car banana crashed
car crashedddd
^ the above shouldn't matchd`
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/