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 |
Why should I use the -w argument with my Perl programs?
How will you declare a variable in perl?
What does file test operators do in perl?
Does Perl have reference type?
Explain ivalue?
How many types of primary data structures in Perl and what do they mean?
What is the difference between use and require in perl programming?
Write a cgi program to show the header part?
Define operators used in perl?
Explain the meaning of perl one-liner?
What is the purpose of goto expr statement?
How do I replace every character in a file with a comma?