Skip to content

Commit b7a6610

Browse files
authored
gh-73137: Added sub-subsection headers for flags in re (#93000)
Fixes #73137
1 parent ac718d3 commit b7a6610

File tree

1 file changed

+42
-30
lines changed

1 file changed

+42
-30
lines changed

Doc/library/re.rst

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -667,40 +667,14 @@ functions are simplified versions of the full featured methods for compiled
667667
regular expressions. Most non-trivial applications always use the compiled
668668
form.
669669

670+
671+
Flags
672+
^^^^^
673+
670674
.. versionchanged:: 3.6
671675
Flag constants are now instances of :class:`RegexFlag`, which is a subclass of
672676
:class:`enum.IntFlag`.
673677

674-
.. function:: compile(pattern, flags=0)
675-
676-
Compile a regular expression pattern into a :ref:`regular expression object
677-
<re-objects>`, which can be used for matching using its
678-
:func:`~Pattern.match`, :func:`~Pattern.search` and other methods, described
679-
below.
680-
681-
The expression's behaviour can be modified by specifying a *flags* value.
682-
Values can be any of the following variables, combined using bitwise OR (the
683-
``|`` operator).
684-
685-
The sequence ::
686-
687-
prog = re.compile(pattern)
688-
result = prog.match(string)
689-
690-
is equivalent to ::
691-
692-
result = re.match(pattern, string)
693-
694-
but using :func:`re.compile` and saving the resulting regular expression
695-
object for reuse is more efficient when the expression will be used several
696-
times in a single program.
697-
698-
.. note::
699-
700-
The compiled versions of the most recent patterns passed to
701-
:func:`re.compile` and the module-level matching functions are cached, so
702-
programs that use only a few regular expressions at a time needn't worry
703-
about compiling regular expressions.
704678

705679
.. class:: RegexFlag
706680

@@ -825,6 +799,41 @@ form.
825799
Corresponds to the inline flag ``(?x)``.
826800

827801

802+
Functions
803+
^^^^^^^^^
804+
805+
.. function:: compile(pattern, flags=0)
806+
807+
Compile a regular expression pattern into a :ref:`regular expression object
808+
<re-objects>`, which can be used for matching using its
809+
:func:`~Pattern.match`, :func:`~Pattern.search` and other methods, described
810+
below.
811+
812+
The expression's behaviour can be modified by specifying a *flags* value.
813+
Values can be any of the following variables, combined using bitwise OR (the
814+
``|`` operator).
815+
816+
The sequence ::
817+
818+
prog = re.compile(pattern)
819+
result = prog.match(string)
820+
821+
is equivalent to ::
822+
823+
result = re.match(pattern, string)
824+
825+
but using :func:`re.compile` and saving the resulting regular expression
826+
object for reuse is more efficient when the expression will be used several
827+
times in a single program.
828+
829+
.. note::
830+
831+
The compiled versions of the most recent patterns passed to
832+
:func:`re.compile` and the module-level matching functions are cached, so
833+
programs that use only a few regular expressions at a time needn't worry
834+
about compiling regular expressions.
835+
836+
828837
.. function:: search(pattern, string, flags=0)
829838

830839
Scan through *string* looking for the first location where the regular expression
@@ -1061,6 +1070,9 @@ form.
10611070
Clear the regular expression cache.
10621071

10631072

1073+
Exceptions
1074+
^^^^^^^^^^
1075+
10641076
.. exception:: error(msg, pattern=None, pos=None)
10651077

10661078
Exception raised when a string passed to one of the functions here is not a

0 commit comments

Comments
 (0)