Python Lookahead

Python look ahead explained.

Positive Lookahead

Python positive lookahead matches at a position where the pattern inside the lookahead can be matched. Matches only the position. It does not consume any characters or expand the match.

Example

Consider the following string:

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

Positive lookahead assertion can help us to find all words followed by the word scientific.

Create a free account to view this lesson.

Continue your learning journey with a 14-day free trial.

By signing up, you agree to Educative's Terms of Service and Privacy Policy