preg_match('/^([a-z0-9]([-a-z0-9]*[a-z0-9])?\.)+((a[cdefgilmnoqrstuwxz]|aero|arpa)|(b[abdefghijmnorstvwyz]|biz)|(c[acdfghiklmnorsuvxyz]|cat|com|coop)|d[ejkmoz]|(e[ceghrstu]|edu)|f[ijkmor]|(g[abdefghilmnpqrstuwy]|gov)|h[kmnrtu]|(i[delmnoqrst]|info|int)|(j[emop]|jobs)|k[eghimnprwyz]|l[abcikrstuvy]|(m[acdghklmnopqrstuvwxyz]|mil|mobi|museum)|(n[acefgilopruz]|name|net)|(om|org)|(p[aefghklmnrstwy]|pro)|qa|r[eouw]|s[abcdeghijklmnortvyz]|(t[cdfghjklmnoprtvwz]|travel)|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw])$/i',
$domainname);
dali
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
> Behalf Of speed3r
> Sent: Tuesday, 27 January 2009 9:59 a.m.
> To: NZ PHP Users Group
> Subject: [phpug] Re: string handling
>
>
> Amen to that. Of course substr($hoststr, strrpos('.', $hoststr)+1)
> will get you the characters immediately following the last . character
> in the string. Now show me how you prove it's a top-level domain!
> (Especially now the naming schema has been relaxed).
>
>
> On Jan 27, 9:06 am, Matias Gertel <[email protected]> wrote:
> > Be really carefull when using code wich assumes certain conditions!
> > Why this regular expersion will fail half of the time:
> > - It assumes the url starts with www. Wrong! eg: mail.google.com
> > - It assumes the url has 4 parts. Wrong! eg:www.google.com
> > - It assumes the 3rd part has 2 characters. Wrong:
> eg:www.google.com.au
> > - It assumes the 4th part has 2 characters. Wrong!
> eg:www.maps.google.com
> >
> > Any of the other examples provided in this thread will work as a
> > charm, but the errors above are common in people who concentrate on
> > solving one example instead of thinking about the big picture.
>
>
--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---