Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matching with pattern list giving unexpected results #33

Open
vanderhoffs opened this issue Jan 20, 2019 · 4 comments
Open

Matching with pattern list giving unexpected results #33

vanderhoffs opened this issue Jan 20, 2019 · 4 comments

Comments

@vanderhoffs
Copy link

I am trying to match a source array to a pattern array (I process the source list one item at a time)

sourceList := []string{"test.20190101.120000", "test.20190101.130000", "test.20190101.140000"}
patternList := []string{"test.201901.12*", "test.201901.14*"}

gives the expected results
Match List [test.20190101.120000 test.20190101.130000 test.20190101.140000] to Patterns [test.201901.12* test.201901.14*]
Match Item test.20190101.120000 to Patterns [test.201901.12* test.201901.14*] true
Match Item test.20190101.130000 to Patterns [test.201901.12* test.201901.14*] false
Match Item test.20190101.140000 to Patterns [test.201901.12* test.201901.14*] true

but If I change the pattern to (see the first pattern in the list - I took out the first ".")
sourceList := []string{"test.20190101.120000", "test.20190101.130000", "test.20190101.140000"}
patternList := []string{"test201901.12*", "test.201901.14*"}

I get the unexpected results - nothing matches!
Match List [test.20190101.120000 test.20190101.130000 test.20190101.140000] to Patterns [test201901.12* test.201901.14*]
Match Item test.20190101.120000 to Patterns[test201901.12* test.201901.14*] false
Match Item test.20190101.130000 to Patterns [test201901.12* test.201901.14*] false
Match Item test.20190101.140000 to Patterns [test201901.12* test.201901.14*] false

If it is a problem with the pattern, I could see the first source entry not matching but expected the third source entry to match as in the first test as it is the same.

Am I misunderstanding the use of a pattern array?

@vanderhoffs
Copy link
Author

here is the go code i used

func findMatches(sl, pl []string) (ml []string) {
gp := "{" + strings.Join(pl, ",") + "}"
g := glob.MustCompile(gp)
Log.Infof("Match List %s to Patterns %s", sl, pl)
for _, s := range sl {
m := g.Match(s)
if m {
ml = append(ml, s)
}
Log.Infof("Match Item %s to Patterns %s %v", s, pl, m)
}
return ml
}

@gobwas
Copy link
Owner

gobwas commented Feb 10, 2019

Hi there. Could you please to test it against feature/v0.3 branch?

@AlmogBaku
Copy link

@gobwas are you plan to release soon?

@gobwas
Copy link
Owner

gobwas commented Mar 13, 2019

@AlmogBaku I am planning, yes. Do you have same problems? Could you try it over feature/v0.3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants