glob icon indicating copy to clipboard operation
glob copied to clipboard

Unexpected escaping behavior

Open aeneasr opened this issue 6 years ago • 1 comments

Take the following code:

package main

import (
	"fmt"

	"github.com/gobwas/glob"
)

func main() {
	var g glob.Glob

	// create simple glob
	g = glob.MustCompile("foo\\bar")
	fmt.Printf("%+v", g.Match("foo\\bar"))
}

It returns false although I would expect true. Using fmt.Printf("%+v", g.Match("foobar")) return true, although I would expect false.

aeneasr avatar Nov 14 '19 14:11 aeneasr

I understand now that \\b matches literal b. To achieve the above I would need to use foo\\\\bar

aeneasr avatar Nov 14 '19 14:11 aeneasr