如何使用Ruby on Rails从电子邮件中提取所有URls /链接?

Anu*_*Anu 3 ruby ruby-on-rails ruby-on-rails-3

我正在建立一个书签网站.我想从电子邮件中提取所有URI /链接.我的网站正在使用Ruby on Rails.

如何提取收到的电子邮件内容的所有网址?

the*_*Man 11

Ruby的内置URI模块已经这样做了:

来自extract文档:

require "uri"

URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.")
# => ["http://foo.example.com/bla", "mailto:test@example.com"]
Run Code Online (Sandbox Code Playgroud)