|
95 | 95 | <li><a href="https://nostarch.com/blog/2022-holiday-gift-guide">NoStarch Press</a> — Holiday Gift Guide, 35% off until Nov 28</li> |
96 | 96 | <li><a href="https://media.pragprog.com/newsletters/2022-11-18.html">The Pragmatic Bookshelf</a> — 40% off on all ebooks and audio books</li> |
97 | 97 | <li><a href="https://deals.manning.com/thanksgiving/">Manning Publications</a> — save 50% when you buy 2 or more eBooks, liveProjects, or liveVideos</li> |
98 | | -<li><a href="https://mailchi.mp/leanpub/weekly-sale-2022-nov-black-friday">Leanpub Weekly Sale</a> — offers for programming books, bundles and courses</li> |
| 98 | +<li><a href="https://mailchi.mp/leanpub/monthly-sale-2022-november-black-friday">Leanpub Monthly Sale</a> — offers for programming books, bundles and courses</li> |
99 | 99 | <li><a href="https://realpython.com/giveaway/black-friday/">Real Python Giveaway</a> — a chance to win one of three prizes, until Nov 25</li> |
100 | 100 | <li><a href="https://github.com/0x90n/InfoSec-Black-Friday">InfoSec Hack Friday</a> — InfoSec related software/tools</li> |
101 | 101 | <li><a href="https://opsdisk.gumroad.com/l/cphlab/blackfriday2022">The Cyber Plumber's Lab Guide and Interactive Access</a> — 50% OFF</li> |
|
1983 | 1983 | <entry xml:lang="en"> |
1984 | 1984 | <title>Python 3.11: possessive quantifiers and atomic grouping added to re module</title> |
1985 | 1985 | <published>2022-05-07T00:00:00+00:00</published> |
1986 | | - <updated>2022-08-24T00:00:00+00:00</updated> |
| 1986 | + <updated>2022-11-25T00:00:00+00:00</updated> |
1987 | 1987 | <link rel="alternate" href="https://learnbyexample.github.io/python-regex-possessive-quantifier/" type="text/html"/> |
1988 | 1988 | <id>https://learnbyexample.github.io/python-regex-possessive-quantifier/</id> |
1989 | 1989 | <content type="html"><p>Quoting from <a href="https://docs.python.org/3.11/whatsnew/3.11.html">What's New In Python 3.11</a>:</p> |
|
2021 | 2021 | </blockquote> |
2022 | 2022 | <br> |
2023 | 2023 | <h2 id="possessive-quantifiers">Possessive quantifiers<a class="zola-anchor" href="#possessive-quantifiers" aria-label="Anchor link for: possessive-quantifiers">🔗</a></h2> |
2024 | | -<p>Until Python 3.10, you had to use alternatives like the third-party <a href="https://pypi.org/project/regex/">regex module</a> for possessive quantifiers. The <code>re</code> module supports possessive quantifiers from Python 3.11 version. This version is currently under development, see <a href="https://www.python.org/download/pre-releases/">Pre-release</a> page on the Python site for download links and other details.</p> |
| 2024 | +<p>Until Python 3.10, you had to use alternatives like the third-party <a href="https://pypi.org/project/regex/">regex module</a> for possessive quantifiers. The <code>re</code> module supports possessive quantifiers from Python 3.11 version.</p> |
2025 | 2025 | <p>The difference between greedy and possessive quantifiers is that possessive will not backtrack to find a match. In other words, possessive quantifiers will always consume every character that matches the pattern on which it is applied. Syntax wise, you need to append <code>+</code> to greedy quantifiers to make it possessive, similar to adding <code>?</code> for non-greedy case.</p> |
2026 | 2026 | <p>Unlike greedy or non-greedy quantifiers, <code>:.*+apple</code> will never match, because <code>.*+</code> will consume rest of the line, leaving no way to match <code>apple</code>.</p> |
2027 | 2027 | <pre data-lang="python" style="background-color:#f5f5f5;color:#1f1f1f;" class="language-python "><code class="language-python" data-lang="python"><span>$ python3</span><span style="color:#b3933a;">.11 </span><span style="color:#72ab00;">-</span><span>q |
|
0 commit comments