From ef83a34e5e695c9f01f7604f29ece0bcda8061ed Mon Sep 17 00:00:00 2001 From: Wolfgang Ulmer Date: Sat, 22 Jul 2023 09:36:31 +0000 Subject: [PATCH 1/2] Add link to string escape sequences in re module --- Doc/library/re.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/re.rst b/Doc/library/re.rst index b7510b93d75427..c73e726e9541fa 100644 --- a/Doc/library/re.rst +++ b/Doc/library/re.rst @@ -632,8 +632,8 @@ character ``'$'``. single: \x; in regular expressions single: \\; in regular expressions -Most of the standard escapes supported by Python string literals are also -accepted by the regular expression parser:: +Most of the :ref:`standard escapes ` supported by Python +string literals are also accepted by the regular expression parser:: \a \b \f \n \N \r \t \u From 691e371e3fc5f37029f98223c8518f6e7a01d363 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulmer Date: Sat, 22 Jul 2023 10:32:31 +0000 Subject: [PATCH 2/2] Introduce header for escape sequences and use more common name for reference text --- Doc/library/re.rst | 2 +- Doc/reference/lexical_analysis.rst | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Doc/library/re.rst b/Doc/library/re.rst index c73e726e9541fa..351f98ec97696e 100644 --- a/Doc/library/re.rst +++ b/Doc/library/re.rst @@ -632,7 +632,7 @@ character ``'$'``. single: \x; in regular expressions single: \\; in regular expressions -Most of the :ref:`standard escapes ` supported by Python +Most of the :ref:`escape sequences ` supported by Python string literals are also accepted by the regular expression parser:: \a \b \f \n diff --git a/Doc/reference/lexical_analysis.rst b/Doc/reference/lexical_analysis.rst index 47062f86810e91..dde7ba1d941dce 100644 --- a/Doc/reference/lexical_analysis.rst +++ b/Doc/reference/lexical_analysis.rst @@ -549,6 +549,10 @@ retained), except that three unescaped quotes in a row terminate the literal. ( .. _escape-sequences: + +Escape sequences +^^^^^^^^^^^^^^^^ + Unless an ``'r'`` or ``'R'`` prefix is present, escape sequences in string and bytes literals are interpreted according to rules similar to those used by Standard C. The recognized escape sequences are: