File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change 4444)
4545
4646DEFAULT_ARTIST_SEPARATORS = [
47- "feat\\ ." ,
47+ "feat." ,
4848 "featuring" ,
4949 "&" ,
50- "vs\\ ." ,
51- "\\ bx \\ b " , # Match "x" only as whole word
50+ "vs." ,
51+ "x " , # Match "x" only as whole word
5252 "/" ,
5353 "+" ,
5454 "and" ,
55- "\\ |" ,
55+ "|" ,
5656]
5757
5858
@@ -100,10 +100,18 @@ def split_on_separators(text, separators):
100100 if not seps :
101101 return [text ]
102102
103- # One regex: separators at token boundaries (no letters/digits touching)
104- # (?<!\S) == start or whitespace; (?!\S) == end or whitespace
105- alt = "|" .join (re .escape (s ) for s in seps ) # escape special chars
106- pattern = rf"(?<!\S)(?:{ alt } )(?!\S)"
103+ # Build patterns: word boundaries for pure alphanumeric, no boundaries for others
104+ patterns = []
105+ for s in seps :
106+ escaped = re .escape (s )
107+ if s .replace (" " , "" ).isalnum (): # treat spaced separators like symbols
108+ # Alphanumeric needs word boundaries (like "x", "and")
109+ patterns .append (rf"\b{ escaped } \b" )
110+ else :
111+ # Symbols like "/", " / " need no boundaries
112+ patterns .append (escaped )
113+
114+ pattern = "|" .join (patterns )
107115
108116 if not re .search (pattern , text , flags = re .IGNORECASE ):
109117 return [text ]
You can’t perform that action at this time.
0 commit comments