Possible Duplicate:
Regular expression to match DNS hostname or IP Address?
I need regular expression to get the IP address from email header. There are lot's of header under received Section.
But I want to read ipaddress only from the line which have pattern like this.
Received: from unknown 124.253.91.178 by rediffmail.com via HTTP; 11 Jan 2013 10:10:35 -0000
I tried the below regex, But it returns all the ip address of email header text.
preg_match_all("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $this->email, $matches);
I want to match Received:
and from
word and ip Address in the one line. Ip address can be IPv6 or IPv4