On 2020-02-27, Stefan Ram <r...@zedat.fu-berlin.de> wrote: > One can count overlapping occurences as follows. > >|>>> print(len(findall('(?=aa)','caaaab'))) >|3 > > Every web page says that lookahead assertions do > not consume nor move the "current position". > > But what mental model can I make of the regex > engine that explains why it is not caught in an > endless loop matching "aa" at the same position > again and again and never advancing to the other > occurences?
Simply that when it's returning multiple matches it knows once it's found a match at position <x> to start looking for the next potential match at position <x + 1> ? -- https://mail.python.org/mailman/listinfo/python-list