package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?i)create\s+table\s*`\w*`\s*\(\n\s*`([\w\-_]*)`\s*([\w]*).*(auto_increment)([\n\s\w()',`]*)(primary key)\s*\(`([\w\-_]*)`\).*\n.*engine\s*=\s*(InnoDB).*charset\s*=\s*([\w\-]*);`)
var str = `CREATE TABLE \`column_statiskey_map\` (
\`ID\` int(11) NOT NULL AUTO_INCREMENT,
\`Platform\` varchar(255) NOT NULL,
\`ColumnName\` varchar(255) NOT NULL DEFAULT '',
\`Statiskey\` varchar(255) NOT NULL DEFAULT '',
\`Status\` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (\`ID\`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8;`
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/