充分表达我有一个正则表达式查找一个URL像一些文字:为的findall
my_urlfinder = re.compile(r'\shttp:\/\/(\S+.|)blah.com/users/(\d+)(\/|)')
text = "blah blah http://blah.com/users/123 blah blah http://blah.com/users/353"
for match in my_urlfinder.findall(text):
print match #prints an array with all the individual parts of the regex
如何获得完整的URL?目前匹配只是打印出匹配的部分(我需要其他东西)...但我也想要完整的网址。
最简单的将是增加一个额外的括号,包围了整个正则表达式。然后你将它与零件一起得到! – alexis 2013-03-06 14:51:58