From 5a0aa7bcdbda5d0ef5a95e3d8fd527e8967f7bb7 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Fri, 8 Dec 2023 19:41:08 -0500 Subject: [PATCH] handled words in files --- main.go | 11 +++++++++++ 1 file changed, 11 insertions(+) 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