我想解析html内容,并保留从A到B的内容 例如:
some content1...
<!-- begin_here -->
some content2
<!-- end_here -->
some content3
将成为
<!-- begin_here -->
some content2
<!-- end_here -->
现在,我用sed来做:
sed '/begin_here/,/end_here/!d' file.html > file2.html
但是,为了跨平台的目的,我想使用python重写它。 我对python中的regex不是很熟悉。 能给我一些提示吗? 非常感谢:)
使用多行正则表达式
不需要正则表达式也可以这样做,例如:
相关问题 更多 >
编程相关推荐