Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Write a simple regular expression to match an IP address,
e-mail address, city-state-zipcode combination.

Answer Posted / jayakumar.b

sub validate_ip {

my $ip = shift;

if ( $ip =~ m/^([1-9]|1[0-9]{1,2}|2[0-4]\d|25[0-5])(\.([0-9]|1[0-9]{1,2}|2[0-4]\d|25[0-5])){3}$/ ) {
return 0;
} else {
return 1;
}
}

validate_ip("127.0.0.1");

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are scalar data and scalar variables?

1187


Explain what is lvalue?

1072


You want to download the contents of a url with perl. How would you do that?

928


Why aren't Perl's patterns regular expressions?

1249


How many types of primary data structures in Perl and what do they mean?

1465


Explain substr function in perl?

1086


What does 'do' statement do in perl?

1052


What is perl unshift array function?

1114


How do you find the length of an array?

1024


In CPAN module, name an instance you use.

1006


What is stdin in perl?

1008


What is an interpolation in perl?

1045


What are the options that can be used to avoid logic errors in perl?

1005


What is automatic error handling in perl?

1113


Is there any way to add two arrays together?

1028