package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?im)(?<=from|join|table|into|exists|update) (?!IF)(\w+\.*)+`)
var str = `SELECT * FROM COLLECTIONNAME.SCHEMANAME.TABLENAME LEFT JOIN SCHEMANAME.TABLENAME ON A.D = B.D
CREATE TABLE IF NOT EXISTS SCHEMANAME.NEWTABLENAME, SCHEMANAME.NEWTABLENAME
ALTER TABLE SCHEMANAME.EXISTINGTABLENAME
CREATE TABLE table_name (column_1 datatype, column_2 datatype, column_3 datatype);
DELETE FROM table_name WHERE some_column = some_value;
INSERT INTO table_name (column_1, column_2, column_3) VALUES (value_1, 'value_2', value_3);
select * from A join (select top 5 * from B) on B.ID = A.ID where A.ID in (select ID from C where C.DOB = A.DOB)
Select distinct W.WORKER_ID, W.FIRST_NAME, W.Salary
from Table1 W, Table2 W1
where W.Salary = W1.Salary
and W.WORKER_ID != W1.WORKER_ID;
left `
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/