Golang匹配破折号(连字符)

Golang to match dash(hyphen) character

regexp.MustCompile(`[^[:alnum:]\s]`)

This matches -(dash) character

But I want a regex that excludes the dash character.

I tried the following but it greps the + characters:

regexp.MustCompile(`[^[0-9A-Za-z\-]\s]`)
regexp.MustCompile(`[^[0-9A-Za-z-]\s]`)

How do I match characters that are not alphanumeric and not -(dash)?

How do I match characters that are not alphanumeric ,not -(dash) and not a space?

[^A-Za-z0-9\s-]

Remove the extra character classes from your regex. The above regex would be fine.