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 |
What is stdin in perl?
How do you you check the return code of a command in perl?
How the interpreter is used in Perl?
Write an expression or perl script to identify the entered ip address is valid or not?
Can you add two arrays together?
How do find the length of an array?
When would `local $_' in a function ruin your day?
How do you open a file for writing?
What does the qq{ } operator do?
Explain socket programming in perl?
You want to empty an array. How would you do that?
How to close a file in perl?