Ruby Regular expression to match a url [duplicate] Ruby Regular expression to match a url [duplicate] ruby ruby

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


You can try this:

/https?:\/\/[\S]+/

The \S means any non-whitespace character.

(Rubular)