diff options
| author | leshe4ka46 <alex9102naid1@ya.ru> | 2025-10-28 13:42:55 +0300 |
|---|---|---|
| committer | leshe4ka46 <alex9102naid1@ya.ru> | 2025-10-28 13:43:08 +0300 |
| commit | ded279a489631651943b5b65cdb3acb6764cf288 (patch) | |
| tree | 9ea2c846f5efdab6521b4e7236dcbea34c9b544b /pkg/model/card.go | |
| parent | bb833561aa74f02970aee13cdc75973b29716491 (diff) | |
unmarshal all formats, merge them in the single table, users are truly unique
Diffstat (limited to 'pkg/model/card.go')
| -rw-r--r-- | pkg/model/card.go | 5 |
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 { |
