diff --git a/pkg/labels/regexp.go b/pkg/labels/regexp.go index 6c8a131011..705d8cc5f4 100644 --- a/pkg/labels/regexp.go +++ b/pkg/labels/regexp.go @@ -115,9 +115,7 @@ func findSetMatchesFromConcat(re *syntax.Regexp, base string) []string { if len(re.Sub) == 0 { return nil } - for _, sub := range re.Sub { - clearCapture(sub) - } + clearCapture(re.Sub...) matches := findSetMatches(re.Sub[0], base) if matches == nil { return nil diff --git a/pkg/labels/regexp_test.go b/pkg/labels/regexp_test.go index 2dba236710..abaa6b5d3f 100644 --- a/pkg/labels/regexp_test.go +++ b/pkg/labels/regexp_test.go @@ -116,6 +116,7 @@ func TestFindSetMatches(t *testing.T) { {"bar|b|buzz", []string{"bar", "b", "buzz"}}, // Simple sets containing escaped characters. {"fo\\.o|bar\\?|\\^baz", []string{"fo.o", "bar?", "^baz"}}, + // using charclass {"[abc]d", []string{"ad", "bd", "cd"}}, // high low charset different => A(B[CD]|EF)|BC[XY] {"ABC|ABD|AEF|BCX|BCY", []string{"ABC", "ABD", "AEF", "BCX", "BCY"}},