From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 23 Oct 2023 07:31:32 +0000 (+0200) Subject: [3.11] gh-110383: Added explanation about simplest regex use case for quantifiers... X-Git-Tag: v3.11.7~145 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6020a3e736e83f82048fd46dad8719f738f24cdd;p=thirdparty%2FPython%2Fcpython.git [3.11] gh-110383: Added explanation about simplest regex use case for quantifiers. (GH-111110) (#111205) Co-authored-by: Nick Co-authored-by: Hugo van Kemenade --- diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst index 8d95d86ba398..2cc17b4f745c 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