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

Answer Posted / saravanan

$ip="0.25.55.25";

if($ip=~/([0-2]{0,1}[0-5]{0,2})\.([0-2]{0,1}[0-5]{0,2})\.([0-2]{0,1}[0-5]{0,2})\.([0-2]{0,1}[0-5]{0,2})/){
print $ip;
}

This will match for all ip address

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does the’$_’ symbol mean?

573


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.

1800


How does polymorphism work in perl?

519


Explain 'grep' function.

544


Is perl a case sensitive language?

638






How to determine strings length in perl?

539


What are the two ways to get private values inside a subroutine?

455


What are the different types of perl operators?

532


What does the qq{ } operator do?

554


Explain perl. When do you use perl for programming? What are the advantages of programming in perl?

469


Explain the meaning of subroutine?

519


What are the various file operations in perl. Explain with example.

517


Differentiate between arrays and list in perl.

538


What is 'rollback' command in perl?

549


Give an example of using the -n and -p option.

541