8000 gh-119960: Add information about regex flags in re module functions (… · python/cpython@a86e625 · GitHub
[go: up one dir, main page]

Skip to content

Commit a86e625

Browse files
authored
gh-119960: Add information about regex flags in re module functions (#119978)
1 parent b8fb369 commit a86e625

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

@@ -1004,6 +1020,10 @@ Functions
10041020
>>> re.findall(r'(\w+)=(\d+)', 'set width=20 and height=10')
10051021
[('width', '20'), ('height', '10')]
10061022

1023+
The expression's behaviour can be modified by specifying a *flags* value.
1024+
Values can be any of the `flags`_ variables, combined using bitwise OR
1025+
(the ``|`` operator).
1026+
10071027
.. versionchanged:: 3.7
10081028
Non-empty matches can now start just after a previous empty match.
10091029

@@ -1015,6 +1035,10 @@ Functions
10151035
is scanned left-to-right, and matches are returned in the order found. Empty
10161036
matches are included in the result.
10171037

1038+
The expression's behaviour can be modified by specifying a *flags* value.
1039+
Values can be any of the `flags`_ variables, combined using bitwise OR
1040+
(the ``|`` operator).
1041+
10181042
.. versionchanged:: 3.7
10191043
Non-empty matches can now start just after a previous empty match.
10201044

@@ -1070,6 +1094,10 @@ Functions
10701094
character ``'0'``. The backreference ``\g<0>`` substitutes in the entire
10711095
substring matched by the RE.
10721096

1097+
The expression's behaviour can be modified by specifying a *flags* value.
1098+
Values can be any of the `flags`_ variables, combined using bitwise OR
1099+
(the ``|`` operator).
1100+
10731101
.. versionchanged:: 3.1
10741102
Added the optional flags argument.
10751103

@@ -1102,6 +1130,10 @@ Functions
11021130
Perform the same operation as :func:`sub`, but return a tuple ``(new_string,
11031131
number_of_subs_made)``.
11041132

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

11061138
.. function:: escape(pattern)
11071139

0 commit comments

Comments
 (0)
0