str := "/tmp/go-build12312412" str2 := "/tmp/go-uild12312412" sampleRegexp := regexp.MustCompile(`/tmp/go-build\d`) fmt.println(sampleRegexp.MatchString(str)) // true fmt.println(sampleRegexp.MatchString(str2)) // false
https://golangbyexample.com/golang-regex-match-number/