I have a little problem with a regex using the "regexp" package in go.
This regex should return to me the substring inside the brackets "[]"
\[(.*?)\]
used on @class my-div [button] {
should return [ button, hello ]
So, in Go I tried something like:
re := regexp.MustCompile('\[(.*?)\]')
fmt.Println(re.MatchString(header)) // false
return re.FindString(header) // header = "@class my-div [button] {"
And also:
re := regexp.QuoteMeta("\\\[\(\.\*\?\)\\\]") // <= Changed
fmt.Println(re.MatchString(header)) // false
return re.FindString(header) // header = "@class my-div [button] {"
And many other variants, but still doesn't work...
I also tried to use an online regex tester for go, and it works perfectly, so I really don't understand why it doesn't work in go.... http://fiddle.re/57y4c6
Playground: http://play.golang.org/p/Z_-1EEKgaW
Help me please and Thank You for your time!