I have this regex function to extract a specific word in a string
fileName = re.search(r'path1\w([A-Za-z\d]+)', self.fileList[0]).group(1)
path1 is an actual string
What if I would like to replace it by fileName variable where fileName = "path1"
I tried:
print re.search(r'\w([A-Za-z\d]+)' % fileName, self.fileList[0]).group(1)
I got this error:
TypeError: not all arguments converted during string formatting
Why did I get this error ? how to solve this problem