Write a simple regular expression to match an IP address,
e-mail address, city-state-zipcode combination.
Answers were Sorted based on User's Feedback
Answer / anshuman
/^([1-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.([0-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.([0-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.([0-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])$/
All those above answer are wrong...because all of them take
0.0.0.0 as valid IP address which is not the case...with computer science ...
Developed By Anshuman sengupta
Reviewed by Arnab Bose
Tested by Avishek chatterjee
Is This Answer Correct ? | 1 Yes | 7 No |
Answer / raghav
For IP Address
/([0-255])(\.)$1\1$1\1$1/;
For other question answer may vary depending on the
requirement.
Is This Answer Correct ? | 22 Yes | 31 No |
Answer / gopal
I hope this is the right way to match IP address
/((\d{1,3})(\.)){3}\d{1,3}/
Is This Answer Correct ? | 12 Yes | 24 No |
How would you ensure the re-use and maximum readability of your perl code?
How to disable the mod_perl from apache_server as i have used perlfect search on the site and its pagination is not working and the remedy is to disable the mod_perl.
What happens when you return a reference to a private variable?
What does `new $cur->{LINK}' do? (Assume the current package has no new() function of its own.)
How will you get the count of parameters passed to a perl subroutine?
What is Perl?
Consider the following example #! /bin/perl use strict; sub sample { my @arr=(1,2,3,4); return @arr; } my ($a,$b,$c,$d) = &sample; print "$a\n$b\n$c\n$d\n"; In the above code, How can I get the $c without using the arguments such as $a,$b. I don't want to use any array to get the return values.
Explain grooving and shortening of arrays?
How do you you check the return code of a command in perl?
What value is returned by a lone `return;’ statement?
What is the difference between exec and system?
What arguments do you frequently use for the Perl interpreter and what do they mean?