Ruby Regular expression to match a url [duplicate]

The standard URI library provides URI.regexp which is the regular expression for url string.

 require 'uri'
 string.scan(URI.regexp)

http://ruby-doc.org/stdlib/libdoc/uri/rdoc/index.html

Leave a Comment