-
-
Save anonymous/0bad07edf0d13fc77567 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'uri' | |
require 'cgi' | |
require 'pp' | |
#url = "http://stackoverflow.com/questions/3927495/parsing-a-complex-url-in-ruby" | |
url = 'http:// this is clearly not a domain but https and www also .com is here' | |
valid = url.match /^(http|https):\/\/|[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}(:[0-9]{1,5})?(\/.*)?$/ix | |
if valid | |
puts "Thats a domain " | |
pp valid | |
else | |
puts "I dont think that can be taken as a domain" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment