On Mon, Aug 23, 2010 at 10:40 AM, Charles Calvert <cbciv / yahoo.com> wrote: > On Fri, 20 Aug 2010 01:02:56 -0500, Mr zengr <utkarsh2012 / gmail.com> > wrote in <e84b80a0c451613d39971f9a1e8ec4a8 / ruby-forum.com>: > > [snip my question about extracting domain name (e.g. "example.com" > from "www.example.com"). >> >>I think the best way will be actually match with a list of TLDs and >>gTLDs. >> >>Mozilla has a list of domains: >>http://mxr.mozilla.org/mozilla/source/netwerk/dns/src/effective_tld_names.dat > > Wow. That's a big help. Thanks. > >>A stackoverflow question on the same topic: >>http://stackoverflow.com/questions/569137/how-to-get-domain-name-from-url > > Interesting. > >>Their solution is regex. > > As the poster pointed out, matching everything leads to a huge regex, > which is likely to cause maintenance problems (though he indicated > that they started generating the regex from other data to address > that) and would make me concerned about resource allocation, though I > couldn't find anything in the core Ruby Doc about a max length for a > regex. > > On the other hand it might be more performant than looping through a > bunch of substring matches or matching against database records. I > sense some testing in my future. http://github.com/pauldix/domainatrix > Thanks, > -- > Charles Calvert > Moderator - alt.computer.consultants.moderated > Submission Address: accm / celticwolf.net > Contact Address: accm_mod / celticwolf.net > > -- Michael Fellinger CTO, The Rubyists, LLC I check email a couple times daily; to reach me sooner, use: http://awayfind.com/manveru