Skip to content

Instantly share code, notes, and snippets.

@kano4
Created February 23, 2012 15:14
Show Gist options
  • Select an option

  • Save kano4/1893245 to your computer and use it in GitHub Desktop.

Select an option

Save kano4/1893245 to your computer and use it in GitHub Desktop.
url = "http://www.google.co.jp/hoge/moge".scan(/(http:\/\/(\w|\.|!\/)+)/)
url = (url.nil? || url[0].nil?) ? "" : url[0][0]
puts "#{url}" # => http://www.google.co.jp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment