John Salerno wrote: > [EMAIL PROTECTED] wrote: > >>>>> string = 'abababababababab' >>>>> pat = 'aba' >>>>> [pat for s in re.compile('(?='+pat+')').findall(string)] >> ['aba', 'aba', 'aba', 'aba', 'aba', 'aba', 'aba'] > > Wow, I have no idea how to read that RE. First off, what does it match? > Should something come before the parentheses, and that will be what > matches? Also, what are the '+'s doing? Are they literal +s or still > being used as RE syntax?
Nevermind, I get it! The point is that you *aren'* matching anything (except the empty string), and this only to see how many times it occurs, then you are replacing those occurrences with the pattern string. So this is basically like a counter? -- http://mail.python.org/mailman/listinfo/python-list