diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2022-03-22 09:44:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-22 09:44:47 (GMT) |
commit | c6cd3cc93c40363ce704d34a70e6fb73ea1d97a3 (patch) | |
tree | e1443085b290766bc1aa68e95aae302ffbd03728 /Doc/howto | |
parent | 4f97d64c831c94660ceb01f34d51fa236ad968b0 (diff) | |
download | cpython-c6cd3cc93c40363ce704d34a70e6fb73ea1d97a3.zip cpython-c6cd3cc93c40363ce704d34a70e6fb73ea1d97a3.tar.gz cpython-c6cd3cc93c40363ce704d34a70e6fb73ea1d97a3.tar.bz2 |
bpo-47081: Replace "qualifiers" with "quantifiers" in the re module documentation (GH-32028)
It is a more commonly used term.
Diffstat (limited to 'Doc/howto')
-rw-r--r-- | Doc/howto/regex.rst | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst index d574c37..33dca2f 100644 --- a/Doc/howto/regex.rst +++ b/Doc/howto/regex.rst @@ -230,13 +230,13 @@ while ``+`` requires at least *one* occurrence. To use a similar example, ``ca+t`` will match ``'cat'`` (1 ``'a'``), ``'caaat'`` (3 ``'a'``\ s), but won't match ``'ct'``. -There are two more repeating qualifiers. The question mark character, ``?``, +There are two more repeating operators or quantifiers. The question mark character, ``?``, matches either once or zero times; you can think of it as marking something as being optional. For example, ``home-?brew`` matches either ``'homebrew'`` or ``'home-brew'``. -The most complicated repeated qualifier is ``{m,n}``, where *m* and *n* are -decimal integers. This qualifier means there must be at least *m* repetitions, +The most complicated quantifier is ``{m,n}``, where *m* and *n* are +decimal integers. This quantifier means there must be at least *m* repetitions, and at most *n*. For example, ``a/{1,3}b`` will match ``'a/b'``, ``'a//b'``, and ``'a///b'``. It won't match ``'ab'``, which has no slashes, or ``'a////b'``, which has four. @@ -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. -Readers of a reductionist bent may notice that the three other qualifiers 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,}`` is equivalent to ``+``, and ``{0,1}`` is the same as ``?``. It's better to use ``*``, ``+``, or ``?`` when you can, simply because they're shorter and easier @@ -803,7 +803,7 @@ which matches the header's value. Groups are marked by the ``'('``, ``')'`` metacharacters. ``'('`` and ``')'`` have much the same meaning as they do in mathematical expressions; they group together the expressions contained inside them, and you can repeat the contents -of a group with a repeating qualifier, such as ``*``, ``+``, ``?``, or +of a group with a quantifier, such as ``*``, ``+``, ``?``, or ``{m,n}``. For example, ``(ab)*`` will match zero or more repetitions of ``ab``. :: @@ -1326,7 +1326,7 @@ backtrack character by character until it finds a match for the ``>``. The final match extends from the ``'<'`` in ``'<html>'`` to the ``'>'`` in ``'</title>'``, which isn't what you want. -In this case, the solution is to use the non-greedy qualifiers ``*?``, ``+?``, +In this case, the solution is to use the non-greedy quantifiers ``*?``, ``+?``, ``??``, or ``{m,n}?``, which match as *little* text as possible. In the above example, the ``'>'`` is tried immediately after the first ``'<'`` matches, and when it fails, the engine advances a character at a time, retrying the ``'>'`` |