Unexpected result matching windows paths
Opened this issue · 2 comments
nirekin commented
I am trying to match a windows path but the given result is not the expected one:
g := glob.MustCompile("C:\\p1\\p2\\templateTarget[12].yaml")
g.Match("C:\\p1\\p2\\templateTarget1.yaml") // false
I find a workaround replacing all the \\
by /
but it's kind of annoying...
g := glob.MustCompile("C:/p1/p2/templateTarget[12].yaml")
g.Match("C:/p1/p2/templateTarget1.yaml") // true
gobwas commented
Hi @nirekin, there is a QuoteMeta()
call for such cases. Ping me if it does not help :)
nirekin commented
Hi @gobwas,
I have tried to use it but I cant figure how it could be helpful in that case.
Quoting the glob pattern meta characters has no effects, not good nor bad...
g := glob.MustCompile(glob.QuoteMeta("C:\\p1\\p2\\templateTarget[12].yaml"))
g.Match("C:\\p1\\p2\\templateTarget1.yaml") // false
Do you have any additional hint or example?