\ n & lt; Span & gt; Keywords: \ n \ n & lt; A href="https://bbs.csdn.net/tag/40855.html" target="_blank" style="color: # 909090" & gt; Block chain application & lt;/a> \ xa0 \ xa0 & lt; A href="https://bbs.csdn.net/tag/41061.html" target="_blank" style="color: # 909090" & gt; Decentralized & lt;/a> \ xa0 \ xa0 & lt;/span> \ n & lt;/div>
As title, I hope all the content in middle span and delete, test many times to write regular cannot work, which tall person help me write the regular expression? Thank you very much!
CodePudding user response:
S='& lt;/p> \ n & lt; Span & gt; Keywords: \ n \ n & lt; A href="https://bbs.csdn.net/tag/40855.html" target="_blank" style="color: # 909090" & gt; Block chain application & lt;/a> \ xa0 \ xa0 & lt; A href="https://bbs.csdn.net/tag/41061.html" target="_blank" style="color: # 909090" & gt; Decentralized & lt;/a> \ xa0 \ xa0 & lt;/span> \ n & lt;/div> '
P="& lt; Span. * & gt; . * & lt;/span>"
S2=re. Sub (p, "", s, flags.=re DOTALL)
Print (s2)