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
How do I sort a hash by the hash key?
Differentiate between arrays and list in perl.
What is confess function in perl?
What is the syntax used in Perl grep function?
How do I replace every TAB character in a file with a comma?
How do find the length of an array?
Explain string comparison operators in perl.
How to concatenate strings with perl?
Explain goto name?
what are the three groups involved in information sharing?
How to remove a directory in perl?
Differentiate between c++ and perl.
How to open and read data files with Perl
Explain '->' in perl?
How to connect to SQL server through Perl?