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:
https://go.dev/play/p/4gp43BvwRwo

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.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/51915214-d52a-431d-aca4-bbdda2b380een%40googlegroups.com.

Reply via email to