From: tedd on
Rob and Daniel:

As expected, both of your submission were excellent. If this was an
assignment in one of my classes ("as if" I could teach either of you
anything) you would both receive an A+.

Daniel's routine also returned .ie TLD, but that was not stated as a
requirement.

Daniel's routine also allow for full-link parsing, but again that was
not stated as a requirement.

How to deal with duplicate domains was not addressed in the given and
both routines differed on that point.

The given was to parse domain-names, but both routines pulled out
sub-domains as well. Perhaps I am wrong in my understanding of what a
domain name is, but I would normally look at sub domains as not part
of the "domain name". Sub domains are simply extensions of the domain
name, am I right or wrong?

In any event, I will be examining both your code because neither is
the way I solved the problem. Mine was a bit more verbose and clumsy
in comparison. It's always nice to see how the top dog's do it.

Cheers,

tedd

PS: I've been away for the last couple of days.

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
From: "Daniel P. Brown" on
On Wed, Jun 16, 2010 at 13:22, tedd <tedd.sperling(a)gmail.com> wrote:
>
> The given was to parse domain-names, but both routines pulled out
> sub-domains as well. Perhaps I am wrong in my understanding of what a domain
> name is, but I would normally look at sub domains as not part of the "domain
> name". Sub domains are simply extensions of the domain name, am I right or
> wrong?

Technically, a domain name is anything from the TLD and SLD levels
and below. An FQDN (commonly called a "hostname") is in the format
cname.sld.tld.

--
</Daniel P. Brown>
daniel.brown(a)parasane.net || danbrown(a)php.net
http://www.parasane.net/ || http://www.pilotpig.net/
We now offer SAME-DAY SETUP on a new line of servers!
From: Robert Cummings on


Daniel P. Brown wrote:
> On Wed, Jun 16, 2010 at 13:22, tedd <tedd.sperling(a)gmail.com> wrote:
>> The given was to parse domain-names, but both routines pulled out
>> sub-domains as well. Perhaps I am wrong in my understanding of what a domain
>> name is, but I would normally look at sub domains as not part of the "domain
>> name". Sub domains are simply extensions of the domain name, am I right or
>> wrong?
>
> Technically, a domain name is anything from the TLD and SLD levels
> and below. An FQDN (commonly called a "hostname") is in the format
> cname.sld.tld.

Additionally, extracting top level domains is not so simple since it may
have 2 or more parts.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.
From: Shawn McKenzie on
On 06/14/2010 08:14 AM, tedd wrote:
> Hi gang:
>
> Considering all the recent parsing, here's another problem to consider
> -- given any text, parse the domain-names out of it.
>
> You may limit the parsing to the most popular TDL's, such as .com, .net,
> and .org, but the finished result should be an array containing all the
> domain-names found in a text file.
>
> Cheers,
>
> tedd


Not extensively tested:

$domains = array();

if(preg_match_all('/[A-Za-z0-9][-A-Za-z0-9\.]*?\.(com|net|org)/i',
$text, $matches)) {
$domains = array_unique($matches[0]);
}

--
Thanks!
-Shawn
http://www.spidean.com
From: "Daniel P. Brown" on
On Wed, Jun 16, 2010 at 15:52, Robert Cummings <robert(a)interjinn.com> wrote:
>
> Additionally, extracting top level domains is not so simple since it may
> have 2 or more parts.

*Gasp!* The Great Cummings is.... incorrect.

/me faints.

Actually, ccTLD's are just the very last group of letters. For
example, .il, .uk, and .br. However, the ICANN, registrar policies,
or sponsorship requirements for some of them require the use of an SLD
as well. For example, .co.il, .org.uk, and .com.br, respectively.
Some ccTLDs offer the SLD options, but don't require them. For
example, you can register .co.in, .firm.in, .gen.in, or any other
available SLD+ccTLD, or just the ccTLD .in itself.

Still others have no such requirement or even official SLD
endorsements, such as good ol' Canada (Land of Clan Cummings),
Ireland, and here in the US.

--
</Daniel P. Brown>
daniel.brown(a)parasane.net || danbrown(a)php.net
http://www.parasane.net/ || http://www.pilotpig.net/
We now offer SAME-DAY SETUP on a new line of servers!