From 2a1d6734a5623dd9c6ff05c89246894f5e959002 Mon Sep 17 00:00:00 2001 From: Nick Kononov Date: Fri, 20 Oct 2023 15:07:16 +0300 Subject: [PATCH 1/2] Added explanation about simplest regex use case for quantifiers. --- Doc/howto/regex.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst index c19c48301f5848..6bab4392e57da5 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 From 5fa8bdc0fc70724b25b57ede690639377bc8257d Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 21 Oct 2023 17:55:18 +0300 Subject: [PATCH 2/2] Update Doc/howto/regex.rst Co-authored-by: Hugo van Kemenade --- Doc/howto/regex.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst index 6bab4392e57da5..15372e74d6fedf 100644 --- a/Doc/howto/regex.rst +++ b/Doc/howto/regex.rst @@ -245,7 +245,7 @@ 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. +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