aboutsummaryrefslogtreecommitdiff
path: root/pkg/model/card.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/model/card.go')
-rw-r--r--pkg/model/card.go5
1 files changed, 1 insertions, 4 deletions
diff --git a/pkg/model/card.go b/pkg/model/card.go
index 6ed666b..5c9de76 100644
--- a/pkg/model/card.go
+++ b/pkg/model/card.go
@@ -11,18 +11,15 @@ func ParseCardLine(s string) (prefix string, number uint64, bonus string) {
if raw == "" {
return "", 0, ""
}
- // number = last run of digits
if m := regexp.MustCompile(`(\d{3,})\D*$`).FindStringSubmatch(raw); len(m) == 2 {
if n, err := strconv.ParseUint(m[1], 10, 64); err == nil {
number = n
}
}
- // tokens (letters with '-', '/', apostrophes)
tokRe := regexp.MustCompile(`[A-Za-z][A-Za-z'/-]*`)
toks := tokRe.FindAllString(s, -1)
- // prefix = first 2–3 letter all-caps-ish token
for _, t := range toks {
u := strings.ToUpper(t)
if len(u) >= 2 && len(u) <= 3 && regexp.MustCompile(`^[A-Z]{2,3}$`).MatchString(u) {
@@ -30,7 +27,7 @@ func ParseCardLine(s string) (prefix string, number uint64, bonus string) {
break
}
}
- // bonus = all tokens except prefix
+
words := []string{}
for _, t := range toks {
if strings.ToUpper(t) == prefix {