I'm trying to write a regex in Go to verify that a string only has alphanumerics, periods, and underscores. However, I'm running into an error that I haven't seen before and have been unsuccessful at Googling.
Here's the regex:
pattern = regexp.MustCompile(`^[A-Za-z0-9_\.]+`)
Here is the error:
const initializer regexp.MustCompile("^[A-Za-z0-9_\\.]+") is not a constant
What does "not a constant" mean and how do I fix this?
const
in Go is likeconstexpr
in C++, if you know it.