package main import ( "fmt" "regexp" ) func main() { /*src := `CREATE TRIGGER test ON /matrix/entity/aix comment '这是注释' SCHEDULE Every 10 SECOND WHEN name='aix:1' BIND class, id AS myvar PRIORITY 20 GROUP 运维组 STATUS enable begin for _, v in pairs(myvar) do log.info(" class : " .. v.class .. ",id : " .. v.id) end end`*/ src := "select * from /native/cnvvbdos where minute = 202212121647" //pat := regexp.MustCompile(`(?i)(.*?PRIORITY\s+)(?:\d+)(\s*\n)`) //repl := "${1}10${2}" //pat := regexp.MustCompile(`(?i)(.*?GROUP\s+)(?:\S+)(\s*\n)`) pat := fmt.Sprintf(`(?i)%s\s*=\s*(.*)`, "minute") fmt.Println(pat) psuffix := regexp.MustCompile(pat) if match := psuffix.FindStringSubmatch( src ); match != nil { fmt.Println(match[1]) } }