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
What is confess function in perl?
Can you add two arrays together?
What are perl strings?
What is Perl?
Perl regular expressions are greedy" what does this mean?
Why Perl aliases are considered to be faster than references?
What does -> symbol indicates in Perl?
Explain the default scope of variables in perl?
Suppose an array contains @arraycontent=(‘ab’, ‘cd’, ‘ef’, ‘gh’). How to print all the contents of the given array?
How to do comment in perl?
Explain goto label, goto name, and goto expr?
What are the reasons that cookie server can’t handle multiple connections?
What is the tk module?
How to close a file in perl?
Explain substr function in perl?