There is a file with html code. It is necessary to find all tags with style="" and delete style="" I tried to write, it turned out something like that.
import re pattern = 'style="(?P<text>[(\w;:-)]*)' re_style = re.compile(pattern) with open('index.html', 'r') as open_file: for line in open_file: if re_style.search(line): print(re_style.search(line).groups()) But style="(?P<text>[(\w;:-)]*) searches for the first non-letter. I wanted to use groups to search for text in style="" , but how then to remove the found group from the string?
style\s*=\s*"[^"]*"and replace with nothing? doesn’t work? - splash58