Use raw strings in the re module examples. (#4616)

This commit is contained in:
Serhiy Storchaka 2017-11-28 22:51:38 +02:00 committed by GitHub
parent ac577d7d0b
commit c615be5166
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -689,11 +689,11 @@ form.
splits occur, and the remainder of the string is returned as the final element splits occur, and the remainder of the string is returned as the final element
of the list. :: of the list. ::
>>> re.split('\W+', 'Words, words, words.') >>> re.split(r'\W+', 'Words, words, words.')
['Words', 'words', 'words', ''] ['Words', 'words', 'words', '']
>>> re.split('(\W+)', 'Words, words, words.') >>> re.split(r'(\W+)', 'Words, words, words.')
['Words', ', ', 'words', ', ', 'words', '.', ''] ['Words', ', ', 'words', ', ', 'words', '.', '']
>>> re.split('\W+', 'Words, words, words.', 1) >>> re.split(r'\W+', 'Words, words, words.', 1)
['Words', 'words, words.'] ['Words', 'words, words.']
>>> re.split('[a-f]+', '0a3B9', flags=re.IGNORECASE) >>> re.split('[a-f]+', '0a3B9', flags=re.IGNORECASE)
['0', '3', '9'] ['0', '3', '9']
@ -702,7 +702,7 @@ form.
the string, the result will start with an empty string. The same holds for the string, the result will start with an empty string. The same holds for
the end of the string:: the end of the string::
>>> re.split('(\W+)', '...words, words...') >>> re.split(r'(\W+)', '...words, words...')
['', '...', 'words', ', ', 'words', '...', ''] ['', '...', 'words', ', ', 'words', '...', '']
That way, separator components are always found at the same relative That way, separator components are always found at the same relative