Skip to content

Commit

Permalink
fix(formatting): adjust and simplify replace regex (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
nuxencs committed Feb 28, 2024
1 parent 8b8b17a commit 0ea22a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/processor/title.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ func processTitle(title string, matchRelease bool) []string {
t := NewTitleSlice()

// Regex patterns
replaceRegexp := regexp.MustCompile(`[[:punct:]\s\x{00a0}\x{2000}-\x{200f}\x{2026}-\x{202f}\x{205f}-\x{206f}à-üÀ-Ü]`)
// https://www.regular-expressions.info/unicode.html#category
// https://www.ncbi.nlm.nih.gov/staff/beck/charents/hex.html
replaceRegexp := regexp.MustCompile(`[\p{P}\p{Z}\x{00C0}-\x{017E}]`)
questionmarkRegexp := regexp.MustCompile(`[?]{2,}`)
regionCodeRegexp := regexp.MustCompile(`\(.+\)$`)
parenthesesEndRegexp := regexp.MustCompile(`\)$`)
Expand Down
8 changes: 8 additions & 0 deletions internal/processor/title_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ func Test_processTitle(t *testing.T) {
},
want: []string{"What?If", "What?If*"},
},
{
name: "test_25",
args: args{
title: "Shōgun (2024)",
matchRelease: false,
},
want: []string{"Sh?gun*2024?", "Sh?gun*2024", "Sh?gun"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 0ea22a3

Please sign in to comment.