13 lines
256 B
Go
13 lines
256 B
Go
package util
|
|
|
|
import "regexp"
|
|
|
|
// MatchesRegex checks if a string matches a regex pattern
|
|
func MatchesRegex(str, pattern string) (bool, error) {
|
|
re, err := regexp.Compile(pattern)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
return re.MatchString(str), nil
|
|
}
|