Email Validator RE

The FAQchest faqchest at abac.com
Sat Nov 17 01:08:09 CST 2001


~sdpm~

Here is the routine that I use on the FAQchest to parse out individuals
e-mail addresses, but those of the mailing list administrativia.

Actually you can play with it, posting messages to the list with some
e-mail addresses and see how they get cleaned up

-Thierry



$username = '[\w-_]+(\.[\w-_]+)*';
$hostname = '[\w-]+(\.[\w-]+)+';
$email    = "$username\@$hostname";
$zebigexclude = 'listserv|majordomo|listproc|almanac|mailman|lists|-list|-admin|-help|-owner|digest|abuse|request|subscribe|info\@';


# -------------------------------------------------------------
# write new page elements with e-mail address filtered out
sub page_body {
  my $line;
  my $lbodyflg = 0;
  foreach $line (@pagecore) {
    $line =~ /Stop FAQCHEST_AA/ && ( $lbodyflg = 0 );
    $line =~ /Start FAQCHEST_AA/ && ( $lbodyflg++ );
    if ($lbodyflg) {
      if ($line =~ /($email)/) {
        if ($1 !~ /$zebigexclude/i) {
          $line =~ s/$email/\[PRIVACY PROTECTION\]/g;
        }
      }
      $lbodyflg++
    }
    print FILE "$line";
  }
  return 1;
}






Ken Loomis wrote:
> 
> As a learning exercise I had the class develop an RE to validate email
> addresses. Not too original I guess, but at least they could all
> understand the need for doing that.
> 
> We started with this as the simplest test:
> 
>     if ($email =~ /.*\@.*/) {
>                 print "$email is a good email address !\n";
>           else {
>                 print "$email is NOT a good email address !\n";
>            }
>
~sdpm~

The posting address is: san-diego-pm-list at hfb.pm.org

List requests should be sent to: majordomo at hfb.pm.org

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:

    unsubscribe san-diego-pm-list

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.




More information about the San-Diego-pm mailing list