On Sep 24, 2007, at 9:38 PM, Robert Dailey wrote: > Hi, > > I've been reading the python documentation on 'positive lookbehind > assertion' and I don't understand at all how it works. The python > docs give the following example: > > " (?<=abc)def will find a match in "abcdef", since the lookbehind > will back up 3 characters and check if the contained pattern matches." > > Can anyone emphasize more on what this RE operation does? Thanks.
Have you actually tried it out? >>> import re >>> r = re.compile(r'(?<=abc)def') >>> m1 = r.search('aaaabcdeffff') >>> m1.group()'def' 'def' >>> m2 = r.search('bcdefff') >>> m2 == None True So, it matches 'def' but only if it is immediately preceded by 'abc'. Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate & market in style. Visit us online at http://www.myemma.com -- http://mail.python.org/mailman/listinfo/python-list