Python Lookbehind

Python Lookbehind explained.

Positive Lookbehind

(?<=regex) Matches at a position if the pattern inside the lookbehind can be matched ending at that position.

Example

Consider the following string:

begin:learner1:scientific:learner2:scientific:learner3:end

Positive lookbehind assertion can help us to find all words 'scientific', 'scientific' and 'end' preeceded by the words learner{1-3}.

Get hands-on with 1200+ tech skills courses.