On Thu, Dec 2, 2010 at 8:08 AM, Adrian Crenshaw <[email protected]>wrote:

Hey Adrian,


>     I've Googled around and not had much luck finding something better. I'm
> trying to parse a file in Python and extract all IPs. Currently I'm using:
>
> IPsInFile =
> re.findall('(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)',TextBlob)
>
> But this gives me some bad results such as:



Everything that looks like an IP, or everything that's a legal IP?

In perl i'd match something like \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} (sorry
my Python is a bit rusy).

But it all depends on your requirements really.


Cheers,

Chris.
_______________________________________________
Pauldotcom mailing list
[email protected]
http://mail.pauldotcom.com/cgi-bin/mailman/listinfo/pauldotcom
Main Web Site: http://pauldotcom.com

Reply via email to