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)

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

Read more here:

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: