package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?mi)^(?<expressaocompleta>(?:^|\s)(?<tipojoin>right|inner|left)\sjoin\s(?<tabelasjoin>.*)\son\s(?<clausulas>.*(?<fatorcondicional>inner|right|where(?<condicao>.*))?))$`)
var str = `SELECT a, b, c, de, efe
FROM aaa a, bbb b
inner join aaa aa ON aa = aaa
right join vvv aac On vvv.asdw = adadw AND ccc = aadw
left join aaaa aa On aaa = sss WHERE a = 'aa'`
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/