On 06 Sep 2006 13:23:43 -0700, Paul Rubin <http://[EMAIL PROTECTED]> wrote:
>Jim Britain <[EMAIL PROTECTED]> writes: >> I would like to match [123.123.123.123] (including the qualifying >> brackets), but be able to simply return the contents, without the >> brackets. > > > >>> p=r'\[((\d{1,3}\.){3}\d{1,3})\]' > >>> m = 'dsl-kk-dynamic-013.38.22.125.touchtelindia.net [125.22.38.13] (may > >>> be' > >>> g=re.search(p,m) > >>> g.group(1) >'125.22.38.13' > >g.group(1) matches the stuff in the first set of parens, which excludes >the square brackets. Final integration: def identifyHost(self): for line in self.fileContents: if re.search("throttling", line.lower()): p=r'\[((\d{1,3}\.){3}\d{1,3})\]' ip=re.search(p,line) if ip.group(1) in self.ignoreList: continue if not ip.group(1) in self.banList: self.banList.append(ip.group(1)) Thanks for the help. Jim -- -- http://mail.python.org/mailman/listinfo/python-list