url and email validation using Perl Regular expression

#!c:/perl/bin/perl -w
print “Content-Type: text/html \n\n”;
$email=”tspradeepkumar\@yahoo.com”;
print $email;
if($email =~ /^(\w|\-|\_|\.)+\@((\w|\-|\_)+\.)+[a-zA-Z]{2,}$/i)
{
print “\n $email is a valid id”;
}
else
{
print “\n Provide a valid email id”;
}

$url=”http://www.eadhoc.com“;
print “\n $url \n”;
if($url =~ /^http:\/\/+(www)+\.+[a-zA-Z0-9\-]+\.+[a-zA-Z]{2,6}$/i)
{
print “$url is a valid url”;
}
else
{
print “\n Provide a valid url “;
}

Comments

Popular Posts