Regular Expressions Greedy & Reluctant Modifiers in Python

Опубликовано: 25 Июль 2026
на канале: life michael
326
1

When using quantifiers, Python supports two modes. Greedy and reluctant. The greedy mode is the default one. Been greedy, the quantifier will try to match as much as possible in order to get the biggest match result possible. Been reluctant, the quantifier will try to match as little as possible. In order to change the mode into reluctant we should add an extra question mark (?) to the quantifier, as in the following: +?, *? and ??.