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 is the difference between use and require in perl?

838


Explain use of ‘my’ keyword in perl?

923


Define perl scripting?

965


What is boolean context?

973


Write an example explaining the use of symbol tables.

943


How to open and read data files with Perl

1026


How do you turn on the perl warnings?

905


What are the features of perl language?

1060


What is hash?

1037


Explain the functioning of conditional structures in perl.

923


Explain chomp, chop, cpan, tk.

914


How do you match one letter in the current locale?

1000


What is cpan ? What are the modules coming under this?

909


What does this symbol mean '->'?

981


“The methods defined in the parent class will always override the methods defined in the base class”. What does this statement means?

989