mirror of
https://github.com/python/cpython.git
synced 2025-11-03 11:23:31 +00:00
gh-110383: Added explanation about simplest regex use case for quantifiers. (#111110)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
This commit is contained in:
parent
88bac5d504
commit
1172d02f9f
1 changed files with 3 additions and 0 deletions
|
|
@ -245,6 +245,9 @@ You can omit either *m* or *n*; in that case, a reasonable value is assumed for
|
||||||
the missing value. Omitting *m* is interpreted as a lower limit of 0, while
|
the missing value. Omitting *m* is interpreted as a lower limit of 0, while
|
||||||
omitting *n* results in an upper bound of infinity.
|
omitting *n* results in an upper bound of infinity.
|
||||||
|
|
||||||
|
The simplest case ``{m}`` matches the preceding item exactly **m** times.
|
||||||
|
For example, ``a/{2}b`` will only match ``'a//b'``.
|
||||||
|
|
||||||
Readers of a reductionist bent may notice that the three other quantifiers can
|
Readers of a reductionist bent may notice that the three other quantifiers can
|
||||||
all be expressed using this notation. ``{0,}`` is the same as ``*``, ``{1,}``
|
all be expressed using this notation. ``{0,}`` is the same as ``*``, ``{1,}``
|
||||||
is equivalent to ``+``, and ``{0,1}`` is the same as ``?``. It's better to use
|
is equivalent to ``+``, and ``{0,1}`` is the same as ``?``. It's better to use
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue