mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[3.12] gh-119960: Add information about regex flags in re module functions (GH-119978) (#120908)
gh-119960: Add information about regex flags in re module functions (#119978)
(cherry picked from commit a86e6255c3
)
Co-authored-by: Awbert <119314310+SweetyAngel@users.noreply.github.com>
This commit is contained in:
parent
2d6d862706
commit
32d43e5fa2
1 changed files with 32 additions and 0 deletions
|
@ -911,6 +911,10 @@ Functions
|
||||||
``None`` if no position in the string matches the pattern; note that this is
|
``None`` if no position in the string matches the pattern; note that this is
|
||||||
different from finding a zero-length match at some point in the string.
|
different from finding a zero-length match at some point in the string.
|
||||||
|
|
||||||
|
The expression's behaviour can be modified by specifying a *flags* value.
|
||||||
|
Values can be any of the `flags`_ variables, combined using bitwise OR
|
||||||
|
(the ``|`` operator).
|
||||||
|
|
||||||
|
|
||||||
.. function:: match(pattern, string, flags=0)
|
.. function:: match(pattern, string, flags=0)
|
||||||
|
|
||||||
|
@ -925,6 +929,10 @@ Functions
|
||||||
If you want to locate a match anywhere in *string*, use :func:`search`
|
If you want to locate a match anywhere in *string*, use :func:`search`
|
||||||
instead (see also :ref:`search-vs-match`).
|
instead (see also :ref:`search-vs-match`).
|
||||||
|
|
||||||
|
The expression's behaviour can be modified by specifying a *flags* value.
|
||||||
|
Values can be any of the `flags`_ variables, combined using bitwise OR
|
||||||
|
(the ``|`` operator).
|
||||||
|
|
||||||
|
|
||||||
.. function:: fullmatch(pattern, string, flags=0)
|
.. function:: fullmatch(pattern, string, flags=0)
|
||||||
|
|
||||||
|
@ -932,6 +940,10 @@ Functions
|
||||||
corresponding :class:`~re.Match`. Return ``None`` if the string does not match
|
corresponding :class:`~re.Match`. Return ``None`` if the string does not match
|
||||||
the pattern; note that this is different from a zero-length match.
|
the pattern; note that this is different from a zero-length match.
|
||||||
|
|
||||||
|
The expression's behaviour can be modified by specifying a *flags* value.
|
||||||
|
Values can be any of the `flags`_ variables, combined using bitwise OR
|
||||||
|
(the ``|`` operator).
|
||||||
|
|
||||||
.. versionadded:: 3.4
|
.. versionadded:: 3.4
|
||||||
|
|
||||||
|
|
||||||
|
@ -974,6 +986,10 @@ Functions
|
||||||
>>> re.split(r'(\W*)', '...words...')
|
>>> re.split(r'(\W*)', '...words...')
|
||||||
['', '...', '', '', 'w', '', 'o', '', 'r', '', 'd', '', 's', '...', '', '', '']
|
['', '...', '', '', 'w', '', 'o', '', 'r', '', 'd', '', 's', '...', '', '', '']
|
||||||
|
|
||||||
|
The expression's behaviour can be modified by specifying a *flags* value.
|
||||||
|
Values can be any of the `flags`_ variables, combined using bitwise OR
|
||||||
|
(the ``|`` operator).
|
||||||
|
|
||||||
.. versionchanged:: 3.1
|
.. versionchanged:: 3.1
|
||||||
Added the optional flags argument.
|
Added the optional flags argument.
|
||||||
|
|
||||||
|
@ -999,6 +1015,10 @@ Functions
|
||||||
>>> re.findall(r'(\w+)=(\d+)', 'set width=20 and height=10')
|
>>> re.findall(r'(\w+)=(\d+)', 'set width=20 and height=10')
|
||||||
[('width', '20'), ('height', '10')]
|
[('width', '20'), ('height', '10')]
|
||||||
|
|
||||||
|
The expression's behaviour can be modified by specifying a *flags* value.
|
||||||
|
Values can be any of the `flags`_ variables, combined using bitwise OR
|
||||||
|
(the ``|`` operator).
|
||||||
|
|
||||||
.. versionchanged:: 3.7
|
.. versionchanged:: 3.7
|
||||||
Non-empty matches can now start just after a previous empty match.
|
Non-empty matches can now start just after a previous empty match.
|
||||||
|
|
||||||
|
@ -1010,6 +1030,10 @@ Functions
|
||||||
is scanned left-to-right, and matches are returned in the order found. Empty
|
is scanned left-to-right, and matches are returned in the order found. Empty
|
||||||
matches are included in the result.
|
matches are included in the result.
|
||||||
|
|
||||||
|
The expression's behaviour can be modified by specifying a *flags* value.
|
||||||
|
Values can be any of the `flags`_ variables, combined using bitwise OR
|
||||||
|
(the ``|`` operator).
|
||||||
|
|
||||||
.. versionchanged:: 3.7
|
.. versionchanged:: 3.7
|
||||||
Non-empty matches can now start just after a previous empty match.
|
Non-empty matches can now start just after a previous empty match.
|
||||||
|
|
||||||
|
@ -1065,6 +1089,10 @@ Functions
|
||||||
character ``'0'``. The backreference ``\g<0>`` substitutes in the entire
|
character ``'0'``. The backreference ``\g<0>`` substitutes in the entire
|
||||||
substring matched by the RE.
|
substring matched by the RE.
|
||||||
|
|
||||||
|
The expression's behaviour can be modified by specifying a *flags* value.
|
||||||
|
Values can be any of the `flags`_ variables, combined using bitwise OR
|
||||||
|
(the ``|`` operator).
|
||||||
|
|
||||||
.. versionchanged:: 3.1
|
.. versionchanged:: 3.1
|
||||||
Added the optional flags argument.
|
Added the optional flags argument.
|
||||||
|
|
||||||
|
@ -1100,6 +1128,10 @@ Functions
|
||||||
.. versionchanged:: 3.5
|
.. versionchanged:: 3.5
|
||||||
Unmatched groups are replaced with an empty string.
|
Unmatched groups are replaced with an empty string.
|
||||||
|
|
||||||
|
The expression's behaviour can be modified by specifying a *flags* value.
|
||||||
|
Values can be any of the `flags`_ variables, combined using bitwise OR
|
||||||
|
(the ``|`` operator).
|
||||||
|
|
||||||
|
|
||||||
.. function:: escape(pattern)
|
.. function:: escape(pattern)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue