Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 32d43e5

Browse files
picnixzSweetyAngel
andauthored
[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 a86e625) Co-authored-by: Awbert <[email protected]>
1 parent 2d6d862 commit 32d43e5

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Doc/library/re.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,10 @@ Functions
911911
``None`` if no position in the string matches the pattern; note that this is
912912
different from finding a zero-length match at some point in the string.
913913

914+
The expression's behaviour can be modified by specifying a *flags* value.
915+
Values can be any of the `flags`_ variables, combined using bitwise OR
916+
(the ``|`` operator).
917+
914918

915919
.. function:: match(pattern, string, flags=0)
916920

@@ -925,13 +929,21 @@ Functions
925929
If you want to locate a match anywhere in *string*, use :func:`search`
926930
instead (see also :ref:`search-vs-match`).
927931

932+
The expression's behaviour can be modified by specifying a *flags* value.
933+
Values can be any of the `flags`_ variables, combined using bitwise OR
934+
(the ``|`` operator).
935+
928936

929937
.. function:: fullmatch(pattern, string, flags=0)
930938

931939
If the whole *string* matches the regular expression *pattern*, return a
932940
corresponding :class:`~re.Match`. Return ``None`` if the string does not match
933941
the pattern; note that this is different from a zero-length match.
934942

943+
The expression's behaviour can be modified by specifying a *flags* value.
944+
Values can be any of the `flags`_ variables, combined using bitwise OR
945+
(the ``|`` operator).
946+
935947
.. versionadded:: 3.4
936948

937949

@@ -974,6 +986,10 @@ Functions
974986
>>> re.split(r'(\W*)', '...words...')
975987
['', '...', '', '', 'w', '', 'o', '', 'r', '', 'd', '', 's', '...', '', '', '']
976988
989+
The expression's behaviour can be modified by specifying a *flags* value.
990+
Values can be any of the `flags`_ variables, combined using bitwise OR
991+
(the ``|`` operator).
992+
977993
.. versionchanged:: 3.1
978994
Added the optional flags argument.
979995

@@ -999,6 +1015,10 @@ Functions
9991015
>>> re.findall(r'(\w+)=(\d+)', 'set width=20 and height=10')
10001016
[('width', '20'), ('height', '10')]
10011017

1018+
The expression's behaviour can be modified by specifying a *flags* value.
1019+
Values can be any of the `flags`_ variables, combined using bitwise OR
1020+
(the ``|`` operator).
1021+
10021022
.. versionchanged:: 3.7
10031023
Non-empty matches can now start just after a previous empty match.
10041024

@@ -1010,6 +1030,10 @@ Functions
10101030
is scanned left-to-right, and matches are returned in the order found. Empty
10111031
matches are included in the result.
10121032

1033+
The expression's behaviour can be modified by specifying a *flags* value.
1034+
Values can be any of the `flags`_ variables, combined using bitwise OR
1035+
(the ``|`` operator).
1036+
10131037
.. versionchanged:: 3.7
10141038
Non-empty matches can now start just after a previous empty match.
10151039

@@ -1065,6 +1089,10 @@ Functions
10651089
character ``'0'``. The backreference ``\g<0>`` substitutes in the entire
10661090
substring matched by the RE.
10671091

1092+
The expression's behaviour can be modified by specifying a *flags* value.
1093+
Values can be any of the `flags`_ variables, combined using bitwise OR
1094+
(the ``|`` operator).
1095+
10681096
.. versionchanged:: 3.1
10691097
Added the optional flags argument.
10701098

@@ -1100,6 +1128,10 @@ Functions
11001128
.. versionchanged:: 3.5
11011129
Unmatched groups are replaced with an empty string.
11021130

1131+
The expression's behaviour can be modified by specifying a *flags* value.
1132+
Values can be any of the `flags`_ variables, combined using bitwise OR
1133+
(the ``|`` operator).
1134+
11031135

11041136
.. function:: escape(pattern)
11051137

0 commit comments

Comments
 (0)