This has to be something simple, but I've been pulling my hair out for days.
I have made two regexp.MustCompile where one is just a simple punctuation
search and the other is a combination of an identifier plus the punctuation search.
I am building the patterns with two strings that I concatinate as argument to the MustCompile.
The complex Find works, but the simplier one returns nothing.
This is the opposite of what I expected.
Playground:
The code is near trivial,
The output in the playground shows an empty slice when Find is
called on the punctuation, yet
returns the expected slice on the more complex pattern:
output:
><
Heart -
Program exited.
Source:
package main
import (
"fmt"
"regexp"
)
func main() {
var fn = []byte("Heart - Crazy On You")
const nameP = "(([0-9A-Za-z]*)\\s*)*"
const divP = "-*"
var regMulti = regexp.MustCompile(nameP + divP)
var regPunch = regexp.MustCompile(divP)
p := regPunch.Find(fn)
fmt.Printf(">%s<\n", p)
m := regMulti.Find(fn)
fmt.Printf("%s\n", m)
}
Any enlightenment would be greatly appreciated.