【发布时间】:2012-07-28 07:26:13
【问题描述】:
在 Linux 上使用 Python 2.7.3。这是一个逐字的 shell 会话。
>>> f = open("feed.xml")
>>> text = f.read()
>>> import re
>>> regexp1 = re.compile(r'</?item>')
>>> regexp2 = re.compile(r'<item>.*</item>')
>>> regexp1.findall(text)
['<item>', '</item>', '<item>', '</item>', '<item>', '</item>', '<item>', '</item>']
>>> regexp2.findall(text)
[]
这是一个错误,还是我对 Python 正则表达式有什么不理解的地方?
【问题讨论】:
标签: python regex python-2.7