From: Georg Brandl Date: Mon, 12 Jul 2010 09:06:13 +0000 (+0000) Subject: Use raw string literals for regexes containing backlash. X-Git-Tag: v3.2a1~212 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=db4e939206e17c0932a177d186462c8f69f22903;p=thirdparty%2FPython%2Fcpython.git Use raw string literals for regexes containing backlash. --- diff --git a/Doc/library/re.rst b/Doc/library/re.rst index 7873fa82a553..26a5f529fa0c 100644 --- a/Doc/library/re.rst +++ b/Doc/library/re.rst @@ -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.'