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 to renaming a file in perl programming?
How to sort arrays in perl?
How can the user execute a long command repeatedly without typing it again and again?
Explain the internal working of cgi
Is perl a case sensitive language?
Explain a tell function in perl?
Is perl compiler or interpreter?
How do you you check the return code of a command in perl?
What is the tk module?
How to make the following assignment, as arrayreference assignment ? my $arr_ref='[1,2,3,4,4,'elem']';
my @array=('data1','data2'); my @array1=('data1','data2'); my ($i,$k); $i=7; $k=7; while($i){ $array [++$#array] = 'ree'; $i--; print "@array"; } while($k){ push(@array1,'ree'); $k--; print "@array1"; } Are these two while loop are doing the same functionality ? What may be the difference?
How will you open a file in read-only mode in perl?