[Python-checkins] gh-73137: Added sub-subsection headers for flags in re (GH-93000)

miss-islington webhook-mailer at python.org
Sun May 22 22:06:58 EDT 2022


https://github.com/python/cpython/commit/619a67cc0675556065d7bb137727c029fff7d5f8
commit: 619a67cc0675556065d7bb137727c029fff7d5f8
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-05-22T19:06:54-07:00
summary:

gh-73137: Added sub-subsection headers for flags in re (GH-93000)


Fixes GH-73137
(cherry picked from commit b7a6610bc88dfecdd943e8d2817f7cd6b85fb740)

Co-authored-by: Stanley <46876382+slateny at users.noreply.github.com>

files:
M Doc/library/re.rst

diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index b12ce4b9744f9..fd12241312211 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -602,40 +602,14 @@ functions are simplified versions of the full featured methods for compiled
 regular expressions.  Most non-trivial applications always use the compiled
 form.
 
+
+Flags
+^^^^^
+
 .. versionchanged:: 3.6
    Flag constants are now instances of :class:`RegexFlag`, which is a subclass of
    :class:`enum.IntFlag`.
 
-.. function:: compile(pattern, flags=0)
-
-   Compile a regular expression pattern into a :ref:`regular expression object
-   <re-objects>`, which can be used for matching using its
-   :func:`~Pattern.match`, :func:`~Pattern.search` and other methods, described
-   below.
-
-   The expression's behaviour can be modified by specifying a *flags* value.
-   Values can be any of the following variables, combined using bitwise OR (the
-   ``|`` operator).
-
-   The sequence ::
-
-      prog = re.compile(pattern)
-      result = prog.match(string)
-
-   is equivalent to ::
-
-      result = re.match(pattern, string)
-
-   but using :func:`re.compile` and saving the resulting regular expression
-   object for reuse is more efficient when the expression will be used several
-   times in a single program.
-
-   .. note::
-
-      The compiled versions of the most recent patterns passed to
-      :func:`re.compile` and the module-level matching functions are cached, so
-      programs that use only a few regular expressions at a time needn't worry
-      about compiling regular expressions.
 
 
 .. data:: A
@@ -744,6 +718,41 @@ form.
    Corresponds to the inline flag ``(?x)``.
 
 
+Functions
+^^^^^^^^^
+
+.. function:: compile(pattern, flags=0)
+
+   Compile a regular expression pattern into a :ref:`regular expression object
+   <re-objects>`, which can be used for matching using its
+   :func:`~Pattern.match`, :func:`~Pattern.search` and other methods, described
+   below.
+
+   The expression's behaviour can be modified by specifying a *flags* value.
+   Values can be any of the following variables, combined using bitwise OR (the
+   ``|`` operator).
+
+   The sequence ::
+
+      prog = re.compile(pattern)
+      result = prog.match(string)
+
+   is equivalent to ::
+
+      result = re.match(pattern, string)
+
+   but using :func:`re.compile` and saving the resulting regular expression
+   object for reuse is more efficient when the expression will be used several
+   times in a single program.
+
+   .. note::
+
+      The compiled versions of the most recent patterns passed to
+      :func:`re.compile` and the module-level matching functions are cached, so
+      programs that use only a few regular expressions at a time needn't worry
+      about compiling regular expressions.
+
+
 .. function:: search(pattern, string, flags=0)
 
    Scan through *string* looking for the first location where the regular expression
@@ -975,6 +984,9 @@ form.
    Clear the regular expression cache.
 
 
+Exceptions
+^^^^^^^^^^
+
 .. exception:: error(msg, pattern=None, pos=None)
 
    Exception raised when a string passed to one of the functions here is not a



More information about the Python-checkins mailing list