diff --git a/main.go b/main.go index 71d8c19..837c653 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "bufio" "fmt" "os" + "regexp" "strconv" "strings" @@ -41,6 +42,9 @@ func main() { var gtins []string + regex, err := regexp.Compile("[^0-9]") + Error(err) + for _, upc := range upcs { upcLength := len(upc) @@ -57,6 +61,13 @@ func main() { evenNumber := 0 var remainder int + checkForNonNumber := regex.MatchString(upc) + + if checkForNonNumber { + gtins = append(gtins, upc) + continue + } + if upcLength < 8 { gtins = append(gtins, "Cannot process upcs less than 8 digits") continue