fixed pattern regex, fixed pattern AND operation

This commit is contained in:
2025-01-22 10:48:06 +01:00
parent a49e28518b
commit 479d8c274a
3 changed files with 11 additions and 7 deletions

View File

@@ -47,8 +47,9 @@ func matchPattern(conf cfg.Config, line string) bool {
return fuzzy.MatchFold(conf.Patterns[0].Pattern, line)
}
var match bool
var match int
//fmt.Printf("<%s>\n", line)
for _, re := range conf.Patterns {
patmatch := re.PatternRe.MatchString(line)
if re.Negate {
@@ -56,13 +57,16 @@ func matchPattern(conf cfg.Config, line string) bool {
patmatch = !patmatch
}
if match != patmatch {
// toggles match if the last match and current match are different
match = !match
if patmatch {
match++
}
//fmt.Printf("patmatch: %t, match: %d, pattern: %s, negate: %t\n", patmatch, match, re.Pattern, re.Negate)
}
return match
// fmt.Printf("result: %t\n", match == len(conf.Patterns))
//fmt.Println()
return match == len(conf.Patterns)
}
/*