From f48f5953c7cad7ee0031151772c1681c692b6ecc Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 23 Oct 2023 10:22:17 +0300 Subject: [PATCH] gh-110383: Added explanation about simplest regex use case for quantifiers. (GH-111110) (cherry picked from commit 1172d02f9fbfe9e1bc0d45214f8aba8e7430d723) Co-authored-by: Nick Co-authored-by: Hugo van Kemenade --- Doc/howto/regex.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst index 8d95d86ba398b6..2cc17b4f745cb6 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