使用正则表达式获取链接

时间:2017-01-31 03:04:16

标签: ruby-on-rails regex http rest-client

我不确定如何选择带正则表达式的图像链接。我已经尝试过去一小时但没有运气。

我正在尝试选择的响应正文:https://gist.githubusercontent.com/anonymous/53971b49d783b90bf4b997b197ca3ee3/raw/c2a1f7c53ba89d67970ef8222bf5bf456c1679dd/gistfile1.txt

尝试选择“http://img-ineed.com/adsfasdf.jpg”。

谢谢。

1 个答案:

答案 0 :(得分:0)

您可以使用:

string.match(/(https?:\/\/.*\.(?:png|jpg))/i)