Re: Email Verfication Regular Expression

Поиск
Список
Период
Сортировка
От Steve Atkins
Тема Re: Email Verfication Regular Expression
Дата
Msg-id 20050907192145.GA30366@gp.word-to-the-wise.com
обсуждение исходный текст
Ответ на Email Verfication Regular Expression  (Brad Nicholson <bnichols@ca.afilias.info>)
Ответы Re: Email Verfication Regular Expression  (Bruno Wolff III <bruno@wolff.to>)
Re: Email Verfication Regular Expression  (merlyn@stonehenge.com (Randal L. Schwartz))
Re: Email Verfication Regular Expression  (Stephane Bortzmeyer <bortzmeyer@nic.fr>)
Список pgsql-general
On Wed, Sep 07, 2005 at 11:17:10AM -0400, Brad Nicholson wrote:
> Does anybody have regular expression handy to verfiy email addresses?

It's not possible to validate an email address with a regex. If
you're prepared to handwave over things like whitespace and
embedded comments you can validate with a scary big regex.
Take a look at Mail::RFC822::Address from CPAN.

But, depending on what you're doing, validation may not be a good
idea. There are email addresses that are syntactically invalid that
are deliverable and in active use. You might want to look at
just doing some basic sanity checking instead, rather than
full validation - something like


/^[^@]*@(?:[^@]*\.)?[a-z0-9-_]+\.(?:a[defgilmnoqrstuwz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvxyz]|d[ejkmoz]|e[ceghrst]|f[ijkmorx]|g[abdefhilmnpqrstuwy]|h[kmnrtu]|i[delnoqrst]|j[mop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrtwy]|qa|r[eouw]|s[abcdeghijklmnortvyz]|t[cdfghjkmnoprtvwz]|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw]|edu|com|net|org|gov|mil|info|biz|coop|museum|aero|name|pro)$/

This'll exclude email addresses like tv@tv, but the owners of such are used
to their being rejected, and it saves you from a lot of the usual miskeyed
addresses.

Cheers,
  Steve


В списке pgsql-general по дате отправления:

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Re: back references using regex
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: Email Verfication Regular Expression