Check formatting of email address - Perl

Email validation

Snippet Code


  
Rate this page :
  [ 0 votes]

sub ValidEmail { return 0 if $_[0] =~ /(?:[.-_]{2,})|(?:@[.-_])|(?:[.-_]@)|(?:A.)/; return 1 if $_[0] =~ /^[w.-_] @[?[w.-_] .(?:[w.-_]{2,}|[0-9])]?$/; return 0; } if(ValidEmail('email id') { print "OK" } else { print "Not Formatted!"; }

Tags


Ask Questions

Ask Question