【发布时间】:2016-03-13 23:30:26
【问题描述】:
我有这样的 stringText
sText ="""<firstName name="hello morning" id="2342"/>
<mainDescription description="cooking food blog 5 years"/>
<special description="G10X, U16X, U17X, G26X, C32X, G34X, G37X, U39X, C40X, G46X,C49X, U54X, U55X, A58X"/>
"""
我想收到:
烹饪美食博客 5 年
我尝试了许多不同的正则表达式
喜欢:
p = re.compile('<mainDescription description=\"([^\"]+)\"\/>')
print re.match(p, sText)
或
p = re.compile(ur'<mainDescription description="([^"]+)"\/>')
并使用 (.+) 根据regex101.com 我的正则表达式应该可以正常工作,但事实并非如此。 我不知道为什么
【问题讨论】:
标签: python regex regex-negation regex-greedy