找到2个字符之间的字符串正则表达式python

时间:2016-01-26 01:40:57

标签: python regex python-2.7 python-2.x

我正在尝试在html中查找网址。这是我想要匹配的例子:

HREF = “HTTP://(+)”(?:+)

<a href="http://www.etf.rs/" target="_top">

匹配: www.etf.rs/“target =

它应该: www.etf.rs **

如果它匹配一些rubish的东西并不重要,但它的重要性是所有URL都匹配。谢谢!

1 个答案:

答案 0 :(得分:1)

您可以使用re.search

import re

s = '<a href="http://www.etf.rs/" target="_top">'
print re.search('"http://(.*)"\s', s).group(1)

输出:

www.etf.rs/