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

How many data types are there in perl?

529


How to check the status of airplane mode (enable/disable) in perl for Android mobile?

2608


What does next statement do in perl?

571


How can we create perl programs in unix, windows nt, macintosh and os/2 ?

476


How to connect with sqlserver from perl and how to display database table info?

529






How to deleting an existing file in perl programming?

493


What does delete function do in perl?

512


Why we use CGI?

2109


When does circular reference occur?

519


What is the purpose of redo statement?

520


How to concatenate strings in perl?

588


What does 'do' statement do in perl?

495


Explain USE and REQUIREMENT statements?

552


Which statement has an initialization, condition check and increment expressions in its body? Write a syntax to use that statement.

541


How will you open a file in a write-only mode in perl?

474