I think I get it... it's really just a way (so it seems) to make characters get added to the found groups as they're matched. Thanks for your help.
On 9/25/07, Andrew Durdin <[EMAIL PROTECTED]> wrote: > > On 9/25/07, Robert Dailey <[EMAIL PROTECTED]> 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. > > It ensures that the regex will only match following the string in the > lookbehind group, but without capturing that string. > > As the docs say, "(?<=abc)def" will match "abcdef"; but it will not > match "def" (as the "abc" is not there). If it does match, the 0th > group in the match object will be "def". > > In contrast, the regex "abcdef" will also match "abcdef" and not > "def", but the 0th group will be "abcdef". > > The negative lookbehind is the opposite -- e.g. "(?<!abc)def" will > match "def" but not "abcdef". > > Cheers, > > Andrew >
-- http://mail.python.org/mailman/listinfo/python-list