mirror of
https://github.com/beetbox/beets.git
synced 2026-02-01 04:55:38 +01:00
Use a regex substitution in substitute
This commit is contained in:
parent
e613a57ca4
commit
7b5d818603
1 changed files with 3 additions and 2 deletions
|
|
@ -34,8 +34,9 @@ class Substitute(BeetsPlugin):
|
|||
"""Do the actual replacing."""
|
||||
if text:
|
||||
for pattern, replacement in self.substitute_rules:
|
||||
if pattern.match(text):
|
||||
return replacement
|
||||
new_string, number_of_subs_made = re.subn(pattern, replacement, text)
|
||||
if number_of_subs_made > 0:
|
||||
return new_string
|
||||
return text
|
||||
else:
|
||||
return ""
|
||||
|
|
|
|||
Loading…
Reference in a new issue