【发布时间】:2016-06-08 12:36:50
【问题描述】:
我的字符串:
Russia's National Settlement Depository discusses why it believes the biggest blockchain opportunities have yet to be uncovered.<img alt="" height="1" src="http://feeds.feedburner.com/~r/CoinDesk/~4/rvoQUj-KDaw" width="1" />|One of the co-founder of digital currency startup Stellar announced their resignation today.<img alt="" height="1" src="http://feeds.feedburner.com/~r/CoinDesk/~4/xRzN7syt-v0" width="1" />|The editorial board for Bloomberg News has called for a permissive regulatory environment for blockchain development.<img alt="" height="1" src="http://feeds.feedburner.com/~r/CoinDesk/~4/ooQYB2iDxP8" width="1" />|
我想把这 3 个链接放到一个列表中:
http://feeds.feedburner.com/~r/CoinDesk/~4/rvoQUj-KDaw
http://feeds.feedburner.com/~r/CoinDesk/~4/xRzN7syt-v0
http://feeds.feedburner.com/~r/CoinDesk/~4/ooQYB2iDxP8
他们遵循这种模式:
src="http://feeds.feedburner.com/~r/CoinDesk/~4/rvoQUj-KDaw"
我知道我应该使用re.findall(pattern, string) 来实现这一点。
但最大的问题是:我怎样才能建立一个在这里工作的模式?
我不太擅长编写正则表达式模式。我总是感到困惑...几乎完成工作的是这个:
pattern = 'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'
但我得到的只是这个列表:
[u'http://feeds.feedburner.com/', u'http://feeds.feedburner.com/', u'http://feeds.feedburner.com/']
看起来问题出在~r 部分和之后的东西上。
【问题讨论】:
标签: python regex url extract src