Python - Using str.replace with a wildcard
python
Solution
Nope, `str.replace` won't work. You need `re.sub`.
e.g.:
>>> re.sub(r'\(.*\)', '', 'foobar (###)')
'foobar '
Problem
I'm trying to rename folder names named with this pattern: FOLDERNAME (###) I'm trying to get rid of (###), a series of numbers of random length. I would like to use str.replace as show below to do it, but I'm not sure I can use a wildcard this way... ``` folderdir = os.listdir(path) # Listing the folder names for foldername in folderdir: output = foldername.replace("(*)", "") rename() ```