我需要检查 aURL
是否与domain
Ex 匹配:
http://www.opera.com/docs/changelogs/mac/ 匹配:opera.com
http://www.amazon.co.uk/gp/feature.html%3Fie%3DUTF8%26docId%3D1000423923 47 匹配 amazon.co.uk
为此,我写了这个:
require 'net/http'
uri = URI('http://cran.r-url.org/bin/max/')
domain = 'r-url.org'
urlToMatch = uri.host
check = urlToMatch.match(domain)
if check
print "match \n"
else
print "not a match \n"
end
有没有更好的方法来做到这一点?谢谢