0
我想從下面提到的字符串中提取鏈接。只使用正則表達式從字符串中提取鏈接
str = /url?q=http://www.example.com/services/blog/first-article&sa=U&ei...
我用下面的正則表達式來獲取link.But之後的「http」獲取完整的URL,因爲我提到be.What我想要的圖案,該圖案之前,只得到URL「& SA 「(即)"http://www.example.com/services/blog/first-article"
links = re.findall(r'/url\?q=(http://.*)', str)
print links # http:example.com/services/blog/first-article&sa=U&ei...
爲什麼不'r'/ url \?q =(http://.*?)&sa =。*''? – RedX
感謝它的工作。 – user