【发布时间】:2010-09-08 01:50:41
【问题描述】:
我有一个带有 html 的文本文件:
Blah, blah, blah
some text is here.
<div> something here
something else </body></html>
到目前为止,如果标签在一行上,这是可行的:
textfile = open("htmlfile.txt", "r+")
text = textfile.read()
a = re.search('<div.+?<\/html>', text)
repstr = c.group(0)
text = text.replace(repstr, '', 1)
工作正常,我没有嵌套标签。 但是如果标签在多行上,就像第一个例子一样,它就不起作用!我可以用什么来测试多行?
【问题讨论】: