Skip to content

Commit

Permalink
Use raw strings in the re module examples. (pythonGH-4616)
Browse files Browse the repository at this point in the history
(cherry picked from commit c615be5)
  • Loading branch information
serhiy-storchaka authored and miss-islington committed Nov 28, 2017
1 parent cb79c22 commit 20281ed
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Doc/library/re.rst
Original file line number Diff line number Diff line change
Expand Up @@ -668,11 +668,11 @@ form.
splits occur, and the remainder of the string is returned as the final element
of the list. ::

>>> re.split('\W+', 'Words, words, words.')
>>> re.split(r'\W+', 'Words, words, words.')
['Words', 'words', 'words', '']
>>> re.split('(\W+)', 'Words, words, words.')
>>> re.split(r'(\W+)', 'Words, words, words.')
['Words', ', ', 'words', ', ', 'words', '.', '']
>>> re.split('\W+', 'Words, words, words.', 1)
>>> re.split(r'\W+', 'Words, words, words.', 1)
['Words', 'words, words.']
>>> re.split('[a-f]+', '0a3B9', flags=re.IGNORECASE)
['0', '3', '9']
Expand All @@ -681,7 +681,7 @@ form.
the string, the result will start with an empty string. The same holds for
the end of the string::

>>> re.split('(\W+)', '...words, words...')
>>> re.split(r'(\W+)', '...words, words...')
['', '...', 'words', ', ', 'words', '...', '']

That way, separator components are always found at the same relative
Expand Down

0 comments on commit 20281ed

Please sign in to comment.