PaulDotCom mailing list archives
Re: Better RegEX to find IPs
From: Adrian Crenshaw <irongeek () irongeek com>
Date: Wed, 1 Dec 2010 17:34:00 -0500
Just legal IPs, but if it matches 255.255.255.255 and 0.0.0.0 I can live with it. Thanks, Adrian On Wed, Dec 1, 2010 at 5:09 PM, Chris Keladis <ckeladis () gmail com> wrote:
On Thu, Dec 2, 2010 at 8:08 AM, Adrian Crenshaw <irongeek () irongeek com>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 Pauldotcom () mail pauldotcom com http://mail.pauldotcom.com/cgi-bin/mailman/listinfo/pauldotcom Main Web Site: http://pauldotcom.com
_______________________________________________ Pauldotcom mailing list Pauldotcom () mail pauldotcom com http://mail.pauldotcom.com/cgi-bin/mailman/listinfo/pauldotcom Main Web Site: http://pauldotcom.com
Current thread:
- Better RegEX to find IPs Adrian Crenshaw (Dec 01)
- Re: Better RegEX to find IPs Chris Keladis (Dec 01)
- Re: Better RegEX to find IPs Adrian Crenshaw (Dec 01)
- Re: Better RegEX to find IPs teacher1st (Dec 01)
- Re: Better RegEX to find IPs Adrian Crenshaw (Dec 01)
- Re: Better RegEX to find IPs Chris Frederick (Dec 01)
- Re: Better RegEX to find IPs Pat (Dec 01)
- Re: Better RegEX to find IPs Adrian Crenshaw (Dec 01)
- Re: Better RegEX to find IPs Chris Keladis (Dec 01)