re Challenge: More Compact?
David Lees
deblNoNospammy at theworld.com
Sun Jul 15 18:47:35 EDT 2001
Because you would also find non-valid IP address. In fact a split would
not even require them to be numeric. There is a problem with the
original regex approach too because while it does require digits for the
quad, it would still accept invalid values such as 999.257.382.433
david lees
Roman Suzi wrote:
>
> On 15 Jul 2001, Tim Daneliuk wrote:
>
> >The following re is (I think) the description of a legitimate IP addess in
> >"quad" format (IPV4). My question is, can it be made even shorter?
> >
> >ipquad = r"^((\d\d?\d?\.){3}(\d\d?\d?))$"
>
> ipquad = r"^((\d{1,3}\.){3}(\d{1,3}))$"
>
> (Why not just split(it, ".") ?)
>
> Sincerely yours, Roman Suzi
> --
> _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
> _/ Sunday, July 15, 2001 _/ Powered by Linux RedHat 6.2 _/
> _/ "This is Borg. <ESC> is futile <CTRL> is inevitable" _/
More information about the Python-list
mailing list