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



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

Answer / sanjiv

/(\d{3}\.){3}\d+/

Is This Answer Correct ?    3 Yes 6 No

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

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

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

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

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

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

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

Answer / leo

/(\d+)(\.\d+){3}/)

Is This Answer Correct ?    4 Yes 16 No

Post New Answer

More CGI Perl Interview Questions

How would you ensure the re-use and maximum readability of your perl code?

0 Answers  


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.

0 Answers  


What happens when you return a reference to a private variable?

0 Answers  


What does `new $cur->{LINK}' do? (Assume the current package has no new() function of its own.)

0 Answers  


How will you get the count of parameters passed to a perl subroutine?

0 Answers  






What is Perl?

0 Answers  


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.

2 Answers  


Explain grooving and shortening of arrays?

0 Answers  


How do you you check the return code of a command in perl?

0 Answers   HCL,


What value is returned by a lone `return;’ statement?

0 Answers  


What is the difference between exec and system?

0 Answers  


What arguments do you frequently use for the Perl interpreter and what do they mean?

4 Answers  


Categories