Re: Regex
| From: | Miguel Cruz | Date: | Mon, 22 Apr 2002 20:35:33 +0000 |
| Subject: | Re: Regex | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-94055@lists.php.net to get a copy of this message | ||
On Mon, 22 Apr 2002, James Taylor wrote:
> I'm trying to come up with a regular expression that will match the TL
> and Second Level domain names in someone's email address ONLY.
Whatever you're planning on doing with that, I hope you're ready for
addresses that end with .ac.uk and so on; trying to guess an organization
based on the last two terms of the domain name doesn't always work.
> So, say someone's address is "joe@relay.mail.someserver.pacbell.net", I
> need to match ONLY pacbell.net. It shouldn't matter what the address
> looks like, I'm looking for any number of digits, a dot, any number of
> digits, and the end of the line. The closest thing I can come up with
> is /\@.+?(.+\..+)?$/, but, as you can guess, that matches everything
> except the very first character.
/.*[^a-z0-9\-]([a-z0-9\-]+\.[a-z0-9\-]+)$/i
miguel