regexp.Match
or related in a loop SCC-SA6000Compile parses a regular expression and returns, if successful, a Regexp object that can be used to match against text.
When matching in a loop, use regexp.Compile
instead.
import (
"regexp"
)
func foo(data []string) {
for _, s := range data {
matched, err := regexp.MatchString(`^.*$`, data)
// ...
}
}
import (
"regexp"
)
func foo(data []string) {
re, err := regexp.Compile(`^.*$`)
if err != nil {
return
}
for _, s := range data {
matched := re.MatchString(`^.*$`, data)
// ...
}
}