hi all
I need to extract IP addresses from a file and store only the extracted IP addresses in a new file. How do i do it. Do i use regular expression or is there any simple way to do it.
Thanks Paras.
What's the original file look like? What will the new one look like?
the original file is a header of an email file
looks like:
Received: (qmail 27680 invoked from network); 12 Jan 2003 15:21:26 -0000 Received: from dev211.mailshell.com (HELO mailshell.com) (10.1.3.211) by dev50.mailshell.com with SMTP; 12 Jan 2003 15:21:26 -0000 Received: (qmail 1953 invoked by uid 99); 12 Jan 2003 15:21:25 -0000 Received: (qmail 24580 invoked from network); 12 Jan 2003 15:21:24 -0000 Received: from unknown (HELO mta104.cheetahmail.com) (216.15.189.38) by www.mailshell.com with SMTP; 12 Jan 2003 15:21:24 -0000 Date: Sun, 12 Jan 2003 15:21:47 -0000 Message-ID: <amhe2xza9aqaf1bpagqeqbu4syp68c.155373475.987@mta104.circuitcity.chtah.com> From: "circuitcity.com" <circuitcity@circuitcity.chtah.com> To: "Mailshell User" <nospam@mailshell.com> Subject: Act Fast - Great Deals on the Hottest Electronics MIME-Version: 1.0 Reply-To: "circuitcity.com" <support-amhe2xza9aqaf1bpagqeqbu4syp68c@circuitcity.chtah.com> Content-type: multipart/alternative; boundary="=amhe2xza9aqaf1bpagqeqbu4syp68c"
output sud be:
IPs detected = x.x.x.x y.y.y.y ..............
-
preg_match_all all then
/((1?\d{1,2}|2[0-4]\d|25[0-5]).){3}(1?\d{1,2}|2[0-4]\d|25[0-5]){1}$/
Thanks !
Now one more help..
I need to extract urls if present in the file like
http://domain.com/jjj.jsp
What is the reg exp for that.
Paras.