[Python-checkins] r68118 - python/trunk/Lib/re.py
georg.brandl
python-checkins at python.org
Thu Jan 1 13:00:20 CET 2009
Author: georg.brandl
Date: Thu Jan 1 13:00:19 2009
New Revision: 68118
Log:
#4185: clarify escape behavior of replacement strings.
Modified:
python/trunk/Lib/re.py
Modified: python/trunk/Lib/re.py
==============================================================================
--- python/trunk/Lib/re.py (original)
+++ python/trunk/Lib/re.py Thu Jan 1 13:00:19 2009
@@ -145,7 +145,8 @@
"""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 @@
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)
More information about the Python-checkins
mailing list