Does the Golang’s regexp package parse regex differently than others?

Golang isn't behaving as expected when parsing regex. I've tested my reg phrase on regextester and it seems to be working as expected. Here's my code:

func main() {
    tags := regexp.MustCompile(`[^,\s][^\,]*[^,\s]`).Split("foo, bar, baz", -1)
    fmt.Println(tags)
}

Golang, in both my local environemnt and the playground, returns [ , , ] where it should return ["foo", "bar", "baz"]



Read more here: https://stackoverflow.com/questions/67928958/does-the-golangs-regexp-package-parse-regex-differently-than-others

Content Attribution

This content was originally published by justapieceofhuman at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: