gitlab.com/evatix-go/core@v1.3.55/coreutils/stringutil/ToIntUsingRegexMatch.go (about) 1 package stringutil 2 3 import ( 4 "regexp" 5 "strconv" 6 7 "gitlab.com/evatix-go/core/constants" 8 ) 9 10 func ToIntUsingRegexMatch( 11 regEx *regexp.Regexp, 12 s string, 13 ) int { 14 if regEx == nil || !regEx.MatchString(s) { 15 return constants.Zero 16 } 17 18 toInt, err := strconv.Atoi(s) 19 20 if err != nil { 21 return constants.Zero 22 } 23 24 return toInt 25 }