Skip to content

Commit

Permalink
Docs: add some RE raw string notation references
Browse files Browse the repository at this point in the history
  • Loading branch information
adorilson committed Oct 3, 2024
1 parent 17baf98 commit 4e12f7c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Doc/library/re.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ usage of the backslash in string literals now generate a :exc:`SyntaxWarning`
and in the future this will become a :exc:`SyntaxError`. This behaviour
will happen even if it is a valid escape sequence for a regular expression.

The solution is to use Python's raw string notation for regular expression
The solution is to use Python's :ref:`raw string notation <raw-string-notation>`
for regular expression
patterns; backslashes are not handled in any special way in a string literal
prefixed with ``'r'``. So ``r"\n"`` is a two-character string containing
``'\'`` and ``'n'``, while ``"\n"`` is a one-character string containing a
Expand Down Expand Up @@ -231,7 +232,8 @@ The special characters are:
``'*'``, ``'?'``, and so forth), or signals a special sequence; special
sequences are discussed below.

If you're not using a raw string to express the pattern, remember that Python
If you're not using a :ref:`raw string to express the
pattern<raw-string-notation>`, remember that Python
also uses the backslash as an escape sequence in string literals; if the escape
sequence isn't recognized by Python's parser, the backslash and subsequent
character are included in the resulting string. However, if Python would
Expand Down

0 comments on commit 4e12f7c

Please sign in to comment.