import re
s="fig shown abcd.png referring 12254383.png"
p=re.sub("\(.*?).png\", '', s)
print(p)
Output expected: fig shown referring
Please help to remove *.png
Here's a sample of the regex that works:
https://regex101.com/r/HJLzTo/1
pat = re.compile(r'[\w]+\.png')
pat.sub('', "fig shown abcd.png referring 12254383.png")
Result:
'fig shown referring '