Ruby で文字列内の URI を抽出する
某所でそのような話がでていて調べてみたら URI.extract が利用できるようです。
[ソース]
require "uri" text = " あああ http://atnd.org/events/33746 いいい https://f.cloud.github.com/assets/214488/2436964/04c70a28-ade2-11e3-88b7-0ed9a83b4704.gif ううう http://docs.ruby-lang.org/ja/2.1.0/method/URI/s/extract.html " puts URI.extract(text, ["http", "https"])
[出力]
http://atnd.org/events/33746 https://f.cloud.github.com/assets/214488/2436964/04c70a28-ade2-11e3-88b7-0ed9a83b4704.gif http://docs.ruby-lang.org/ja/2.1.0/method/URI/s/extract.html
URI.extract() の戻り値は配列になります。