From python-list Thu Sep 20 13:50:49 2007 From: =?ISO-8859-1?Q?Ricardo_Ar=E1oz?= Date: Thu, 20 Sep 2007 13:50:49 +0000 To: python-list Subject: Re: re question Message-Id: <46F27AB9.8060007 () bigfoot ! com> X-MARC-Message: https://marc.info/?l=python-list&m=119032694521099 Dan Bar Dov wrote: > I'm trying to construct a regular expression to match valid IP address, > without leading zeroes (i.e > 1.2.3.4 , 254.10.0.0 , but not > 324.1.1.1, nor 010.10.10.1 ) > > This is what I come up with, and it does not work. > > r'(^[12]?\d{0,2}\.){3,3}[12]?\d{0,2}' > > What am I doing wrong? > Any common knowledge IP matching RE? > > Thanks, > Dan > r'^[12]\d?\d?.\d{1,3}.\d{1,3}.\d{1,3}$' HTH -- http://mail.python.org/mailman/listinfo/python-list