summaryrefslogtreecommitdiffstats
path: root/Lib/re.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-01-01 12:00:19 (GMT)
committerGeorg Brandl <georg@python.org>2009-01-01 12:00:19 (GMT)
commit2adde0551a51002c9a43bfabf684be0c960ed192 (patch)
tree096493babe0e853e1ea3d2bf9057217c6688f9d9 /Lib/re.py
parentd0eb8f96929f8c2326dd6059f68242cc07b5de86 (diff)
downloadcpython-2adde0551a51002c9a43bfabf684be0c960ed192.zip
cpython-2adde0551a51002c9a43bfabf684be0c960ed192.tar.gz
cpython-2adde0551a51002c9a43bfabf684be0c960ed192.tar.bz2
#4185: clarify escape behavior of replacement strings.
Diffstat (limited to 'Lib/re.py')
-rw-r--r--Lib/re.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/re.py b/Lib/re.py
index ee962bb..2cf7132 100644
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -145,7 +145,8 @@ def sub(pattern, repl, string, count=0):
"""Return the string obtained by replacing the leftmost
non-overlapping occurrences of the pattern in string by the
replacement repl. repl can be either a string or a callable;
- if a callable, it's passed the match object and must return
+ if a string, backslash escapes in it are processed. If it is
+ a callable, it's passed the match object and must return
a replacement string to be used."""
return _compile(pattern, 0).sub(repl, string, count)
@@ -155,7 +156,8 @@ def subn(pattern, repl, string, count=0):
non-overlapping occurrences of the pattern in the source
string by the replacement repl. number is the number of
substitutions that were made. repl can be either a string or a
- callable; if a callable, it's passed the match object and must
+ callable; if a string, backslash escapes in it are processed.
+ If it is a callable, it's passed the match object and must
return a replacement string to be used."""
return _compile(pattern, 0).subn(repl, string, count)