I'm trying to achieve the following:
string = 'C:/some path to mp3/song (7) title and so on (1).mp3'
should become:
C:/some path to mp3/song (7) title and so on.mp3
To match it i'm using the following regex:
pattern = '.*(\s\([0-9]+\))\.mp3'
And the match group contains: (u' (1)',)
however, when i'm trying to substitute the match like so:
processed = re.sub(pattern, '', string)
processed contains an empty string. How can i get re.sub() to only replace the match found above?
string.replace('(1)', '')?'(2)'?(1)and(2)I would still use a string replace ;)[0-9]+, they will be matching any integer, not just 1 or 2.(###)appended to duplicate filenames. So the point is it happens right before the extension, not that it is a digit in parenthesis (hence the persisting(7)in the example).