python 正则表达式删除HTML标签
程序员文章站
2022-04-08 23:19:03
...
实战需求
我们从网络上复制文字,有些讨厌的html标签,请问该如何清除。
[SwiftUI 2.0 NavigationView设置导航条颜色](https://xiaozhuanlan.com/topic/19432)
<abbr class="timeago" title="2020-07-01T19:03:14+08:00" style="box-sizing: border-box; border-bottom: none; cursor: initial; text-decoration: none; font-size: 14px; color: rgb(199, 199, 199);">1 月前</abbr>共1681字
[SwiftUI 2.0 ProgressView 基础教程含代码wwdc20](https://xiaozhuanlan.com/topic/19416)
<abbr class="timeago" title="2020-07-01T09:50:49+08:00" style="box-sizing: border-box; border-bottom: none; cursor: initial; text-decoration: none; font-size: 14px; color: rgb(199, 199, 199);">1 月前</abbr>共2900字
[SwiftUI 2.0 List 实力加强新增呈现分层数据功能(wwdc20 教程含源码)](https://xiaozhuanlan.com/topic/19350)
实战代码
fname = "swiftui"
fname_ext = "md"
rname = fname+"_clear."+fname_ext
rstr = ""
flines = open(fname+"."+fname_ext).read()
rstr = re.sub(r'<.*?>','',flines )
with open(rname,'w') as r:
r.write(rstr)