|
@@ -8,6 +8,7 @@ import (
|
|
|
qu "qfw/util"
|
|
|
"regexp"
|
|
|
"sort"
|
|
|
+ "strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
@@ -201,10 +202,14 @@ func (e *ExtractTask) InitRulePres() {
|
|
|
qu.Try(func() {
|
|
|
rinfo.RuleText = v["s_rule"].(string)
|
|
|
tmp := strings.Split(rinfo.RuleText, "__")
|
|
|
+ var pattern string
|
|
|
+ if strings.Contains(tmp[0], "\\u") {
|
|
|
+ pattern, _ = strconv.Unquote(`"` + tmp[0] + `"`)
|
|
|
+ }
|
|
|
if len(tmp) == 2 {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: tmp[1]}
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(pattern), Replace: tmp[1]}
|
|
|
} else {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: ""}
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(pattern), Replace: ""}
|
|
|
}
|
|
|
e.RulePres = append(e.RulePres, rinfo)
|
|
|
}, func(err interface{}) {
|
|
@@ -232,10 +237,14 @@ func (e *ExtractTask) InitRuleBacks() {
|
|
|
qu.Try(func() {
|
|
|
rinfo.RuleText = v["s_rule"].(string)
|
|
|
tmp := strings.Split(rinfo.RuleText, "__")
|
|
|
+ var pattern string
|
|
|
+ if strings.Contains(tmp[0], "\\u") {
|
|
|
+ pattern, _ = strconv.Unquote(`"` + tmp[0] + `"`)
|
|
|
+ }
|
|
|
if len(tmp) == 2 {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: tmp[1]}
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(pattern), Replace: tmp[1]}
|
|
|
} else {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: ""}
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(pattern), Replace: ""}
|
|
|
}
|
|
|
e.RuleBacks = append(e.RuleBacks, rinfo)
|
|
|
}, func(err interface{}) {
|
|
@@ -282,10 +291,14 @@ func (e *ExtractTask) InitRuleCore() {
|
|
|
qu.Try(func() {
|
|
|
rinfo.RuleText = v["s_rule"].(string)
|
|
|
tmp := strings.Split(rinfo.RuleText, "__")
|
|
|
+ var pattern string
|
|
|
+ if strings.Contains(tmp[0], "\\u") {
|
|
|
+ pattern, _ = strconv.Unquote(`"` + tmp[0] + `"`)
|
|
|
+ }
|
|
|
if len(tmp) == 2 {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: tmp[1]}
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(pattern), Replace: tmp[1]}
|
|
|
} else {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: ""}
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(pattern), Replace: ""}
|
|
|
}
|
|
|
rulePres = append(rulePres, rinfo)
|
|
|
}, func(err interface{}) {
|
|
@@ -312,10 +325,14 @@ func (e *ExtractTask) InitRuleCore() {
|
|
|
qu.Try(func() {
|
|
|
rinfo.RuleText = v["s_rule"].(string)
|
|
|
tmp := strings.Split(rinfo.RuleText, "__")
|
|
|
+ var pattern string
|
|
|
+ if strings.Contains(tmp[0], "\\u") {
|
|
|
+ pattern, _ = strconv.Unquote(`"` + tmp[0] + `"`)
|
|
|
+ }
|
|
|
if len(tmp) == 2 {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: tmp[1]}
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(pattern), Replace: tmp[1]}
|
|
|
} else {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: ""}
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(pattern), Replace: ""}
|
|
|
}
|
|
|
ruleBacks = append(ruleBacks, rinfo)
|
|
|
}, func(err interface{}) {
|
|
@@ -347,6 +364,10 @@ func (e *ExtractTask) InitRuleCore() {
|
|
|
qu.Try(func() {
|
|
|
rinfo.RuleText = v["s_rule"].(string)
|
|
|
tmp := strings.Split(rinfo.RuleText, "__")
|
|
|
+ var pattern string
|
|
|
+ if strings.Contains(tmp[0], "\\u") {
|
|
|
+ pattern, _ = strconv.Unquote(`"` + tmp[0] + `"`)
|
|
|
+ }
|
|
|
if len(tmp) == 2 {
|
|
|
epos := strings.Split(tmp[1], ",")
|
|
|
posm := map[string]int{}
|
|
@@ -358,9 +379,9 @@ func (e *ExtractTask) InitRuleCore() {
|
|
|
posm[rinfo.Field] = qu.IntAll(ks[0])
|
|
|
}
|
|
|
}
|
|
|
- rinfo.RegCore = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Bextract: true, ExtractPos: posm}
|
|
|
+ rinfo.RegCore = &ExtReg{Reg: regexp.MustCompile(pattern), Bextract: true, ExtractPos: posm}
|
|
|
} else {
|
|
|
- rinfo.RegCore = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Bextract: false}
|
|
|
+ rinfo.RegCore = &ExtReg{Reg: regexp.MustCompile(pattern), Bextract: false}
|
|
|
}
|
|
|
ruleCores = append(ruleCores, rinfo)
|
|
|
}, func(err interface{}) {
|
|
@@ -412,10 +433,14 @@ func (e *ExtractTask) InitPkgCore() {
|
|
|
qu.Try(func() {
|
|
|
rinfo.RuleText = v["s_rule"].(string)
|
|
|
tmp := strings.Split(rinfo.RuleText, "__")
|
|
|
+ var pattern string
|
|
|
+ if strings.Contains(tmp[0], "\\u") {
|
|
|
+ pattern, _ = strconv.Unquote(`"` + tmp[0] + `"`)
|
|
|
+ }
|
|
|
if len(tmp) == 2 {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: tmp[1]}
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(pattern), Replace: tmp[1]}
|
|
|
} else {
|
|
|
- rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(tmp[0]), Replace: ""}
|
|
|
+ rinfo.RegPreBac = &ExtReg{Reg: regexp.MustCompile(pattern), Replace: ""}
|
|
|
}
|
|
|
ruleBacks = append(ruleBacks, rinfo)
|
|
|
}, func(err interface{}) {
|