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

Why should I use the -w argument with my Perl programs?

0 Answers  


How will you declare a variable in perl?

0 Answers  


What does file test operators do in perl?

0 Answers  


Does Perl have reference type?

0 Answers  


Explain ivalue?

0 Answers  






How many types of primary data structures in Perl and what do they mean?

0 Answers  


What is the difference between use and require in perl programming?

0 Answers  


Write a cgi program to show the header part?

0 Answers  


Define operators used in perl?

0 Answers  


Explain the meaning of perl one-liner?

0 Answers  


What is the purpose of goto expr statement?

0 Answers  


How do I replace every character in a file with a comma?

0 Answers  


Categories