str="<p class=\"drug-subtitle\"><b>Generic Name:</b> albuterol inhalation (al BYOO ter all)<br><b>Brand Names:</b> <i>Accuneb, ProAir HFA, Proventil, Proventil HFA, ReliOn Ventolin HFA, Ventolin HFA</i></p>"
br=re.match("<p> class=\"drug-subtitle\"[^>]*>(.*?)</p>",str)
br无返回
我使用的正则表达式有什么错误?在
我强烈建议您可以使用一个DOM解析器库,例如lxml和例如cssselect一起使用。在
示例:
固定的正则表达式就是这个。在我指出的第二行,你会发现它对你不起作用的地方。我使用
findall()
方便地访问屏幕上所有匹配的组。在但是,BeautifulSoup将是这类操作的简单选择:
^{pr2}$如果有输入:
你想检查一下:
^{pr2}$存在于输入中,要使用的正则表达式是:
说明:
所以正则表达式中的问题是:
希望这有帮助。在
相关问题 更多 >
编程相关推荐