]> granicus.if.org Git - python/commitdiff
Use raw string literals for regexes containing backlash.
authorGeorg Brandl <georg@python.org>
Mon, 12 Jul 2010 09:06:13 +0000 (09:06 +0000)
committerGeorg Brandl <georg@python.org>
Mon, 12 Jul 2010 09:06:13 +0000 (09:06 +0000)
Doc/library/re.rst

index 7873fa82a553cd98fd4dd44bf72930c3b9318283..26a5f529fa0cbb8c2e680a3506d2fbbf428895dd 100644 (file)
@@ -1230,9 +1230,9 @@ in each word of a sentence except for the first and last characters::
    ...   random.shuffle(inner_word)
    ...   return m.group(1) + "".join(inner_word) + m.group(3)
    >>> text = "Professor Abdolmalek, please report your absences promptly."
-   >>> re.sub("(\w)(\w+)(\w)", repl, text)
+   >>> re.sub(r"(\w)(\w+)(\w)", repl, text)
    'Poefsrosr Aealmlobdk, pslaee reorpt your abnseces plmrptoy.'
-   >>> re.sub("(\w)(\w+)(\w)", repl, text)
+   >>> re.sub(r"(\w)(\w+)(\w)", repl, text)
    'Pofsroser Aodlambelk, plasee reoprt yuor asnebces potlmrpy.'