This is the one I've used. It's broken up into multiple variables, but
you could combine it if you wanted. It'll still match 0.0.0.0 and
255.255.255.255 though.
$REG0TO255 = '(2([0-4][0-9]|5[0-5])|1[0-9]?[0-9]|[1-9][0-9]?|[0-9])';
$REGIP = $REG0TO255 . '(\.' . $REG0TO255 . '){3}';
Chris Frederick
Adrian Crenshaw wrote, On 12/01/10 16:37:
> Thanks, but the one they are calling "Accurate" is the same one I'm
> using as best as I can tell. I don't need to split the the octets.
>
> Thanks,
> Adrian
>
> On Wed, Dec 1, 2010 at 5:14 PM, teacher1st <[email protected]
> <mailto:[email protected]>> wrote:
>
> Some suggestions here:
>
> http://answers.oreilly.com/topic/318-how-to-match-ipv4-addresses-with-regular-expressions/
>
>
>
> On 12/1/2010 4:08 PM, Adrian Crenshaw wrote:
>> Hi All,
>> ��� 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:
>>
>> .106
>> .123.102
>> .128
>> .143
>> .144
>> .186.64
>> .190
>> .2
>> .200.65
>> .208.7
>> .214
>> .24.124.224
>> .250.23.32
>> .36.132.142
>> .73
>> 0.204.35.172
>> 0.36.132.60
>> 0.6.1.32
>> 0.6.1.33
>> 0.64
>> 1.159.84
>> 1.33
>>
>> Any ideas for a better regular expression to use?
>>
>> Thanks,
>> Adrian
>>
>>
>> _______________________________________________
>> Pauldotcom mailing list
>> [email protected] <mailto:[email protected]>
>> http://mail.pauldotcom.com/cgi-bin/mailman/listinfo/pauldotcom
>> Main Web Site: http://pauldotcom.com
>
>
> _______________________________________________
> Pauldotcom mailing list
> [email protected] <mailto:[email protected]>
> http://mail.pauldotcom.com/cgi-bin/mailman/listinfo/pauldotcom
> Main Web Site: http://pauldotcom.com
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Pauldotcom mailing list
> [email protected]
> http://mail.pauldotcom.com/cgi-bin/mailman/listinfo/pauldotcom
> Main Web Site: http://pauldotcom.com
_______________________________________________
Pauldotcom mailing list
[email protected]
http://mail.pauldotcom.com/cgi-bin/mailman/listinfo/pauldotcom
Main Web Site: http://pauldotcom.com