充分表達我有一個正則表達式查找一個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