Re: Email Verification Regular Expression

From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Email Verification Regular Expression
Date: 2005-09-07 16:25:27
Message-ID: 838ac1c6c22c31d17d8d6bf1a7e0a2f7@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> Does anybody have regular expression handy to verfiy email addresses?

CREATE OR REPLACE FUNCTION goodemail(text) RETURNS BOOL LANGUAGE plperl AS
$$
my $lwsp = "(?:(?:\\r\\n)?[ \\t])";
my $specials = '()<>@,;:\\\\".\\[\\]';
my $controls = '\\000-\\037\\177';
my $dtext = "[^\\[\\]\\r\\\\]";
my $domain_literal = "\\[(?:$dtext|\\\\.)*\\]$lwsp*";
my $quoted_string = "\"(?:[^\\\"\\r\\\\]|\\\\.|$lwsp)*\"$lwsp*";
my $atom = "[^$specials $controls]+(?:$lwsp+|\\Z|(?=[\\[\"$specials]))";
my $word = "(?:$atom|$quoted_string)";
my $localpart = "$word(?:\\.$lwsp*$word)*";
my $sub_domain = "(?:$atom|$domain_literal)";
my $domain = "$sub_domain(?:\\.$lwsp*$sub_domain)*";
my $addr_spec = "$localpart\(at)$lwsp*$domain";
my $phrase = "$word*";
my $route = "(?:\(at)$domain(?:,\(at)$lwsp*$domain)*:$lwsp*)";
my $route_addr = "\\<$lwsp*$route?$addr_spec\\>$lwsp*";
my $mailbox = "(?:$addr_spec|$phrase$route_addr)";
my $group = "$phrase:$lwsp*(?:$mailbox(?:,\\s*$mailbox)*)?;\\s*";
my $address = "(?:$mailbox|$group)";
my $EMAILRE = qr{$lwsp*$address};

return $_[0] =~ $EMAILRE ? 1 : 0;

$$;

- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200509071223
https://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAkMfFCgACgkQvJuQZxSWSshBlQCfTIJVNH2SH/g3PaVW4COA9x4q
evUAnRqTbkLI88kr5diqaqBb5jAacXcm
=6OXG
-----END PGP SIGNATURE-----

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ben 2005-09-07 16:35:19 Re: Email Verfication Regular Expression
Previous Message Lincoln Yeoh 2005-09-07 16:14:54 Re: SLOOOOOOOW