mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
wip
Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
This commit is contained in:
parent
d217825af8
commit
0bb2d1954b
|
@ -241,3 +241,32 @@ func optimizeConcatRegex(r *syntax.Regexp) (prefix, suffix, contains string) {
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo remove anchors ^foo$
|
||||||
|
// .*POD.*
|
||||||
|
|
||||||
|
func contains(s, substr string) bool {
|
||||||
|
pos := strings.Index(s, substr)
|
||||||
|
if pos < 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return matchesAnyZeroOrMoreNotNL(s[:pos]) && matchesAnyZeroOrMoreNotNL(s[pos+len(substr):])
|
||||||
|
}
|
||||||
|
|
||||||
|
func matchesAnyZeroOrMoreNotNL(s string) bool {
|
||||||
|
for _, r := range s {
|
||||||
|
if r == '\n' {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func matchesOneZeroOrMoreNotNL(s string) bool {
|
||||||
|
for _, r := range s {
|
||||||
|
if r == '\n' {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len(s) > 0
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue