diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-10-23 07:31:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-23 07:31:56 (GMT) |
commit | 8f94d0f692d4407e92944ec0c994457a5e93afe9 (patch) | |
tree | b5fa6388ee0c5fcc84f2c93e919b46b9704b9481 | |
parent | 9e73c71aa90d8785e2e107595b4f9927a9a06a13 (diff) | |
download | cpython-8f94d0f692d4407e92944ec0c994457a5e93afe9.zip cpython-8f94d0f692d4407e92944ec0c994457a5e93afe9.tar.gz cpython-8f94d0f692d4407e92944ec0c994457a5e93afe9.tar.bz2 |
[3.12] gh-110383: Added explanation about simplest regex use case for quantifiers. (GH-111110) (#111204)
Co-authored-by: Nick <Nikki1993@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
-rw-r--r-- | Doc/howto/regex.rst | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst index c19c483..15372e7 100644 --- a/Doc/howto/regex.rst +++ b/Doc/howto/regex.rst @@ -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 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 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 |