QuestionQ13

Regular Expressions

What output results when the following commands are entered in Python interactive mode?

Question Image

Explanation

In Python regular expressions, .* is greedy by default. Between the first and final literal tag, it consumes the longest possible sequence, so re.findall() returns one string: tag to go tag to sans tag.

Community Discussion

No comments yet. Be the first to start the discussion!