@@ -139,15 +139,19 @@ def search(pattern, string, flags=0):
139139def sub (pattern , repl , string , count = 0 ):
140140 """Return the string obtained by replacing the leftmost
141141 non-overlapping occurrences of the pattern in string by the
142- replacement repl"""
142+ replacement repl. repl can be either a string or a callable;
143+ if a callable, it's passed the match object and must return
144+ a replacement string to be used."""
143145 return _compile (pattern , 0 ).sub (repl , string , count )
144146
145147def subn (pattern , repl , string , count = 0 ):
146148 """Return a 2-tuple containing (new_string, number).
147149 new_string is the string obtained by replacing the leftmost
148150 non-overlapping occurrences of the pattern in the source
149151 string by the replacement repl. number is the number of
150- substitutions that were made."""
152+ substitutions that were made. repl can be either a string or a
153+ callable; if a callable, it's passed the match object and must
154+ return a replacement string to be used."""
151155 return _compile (pattern , 0 ).subn (repl , string , count )
152156
153157def split (pattern , string , maxsplit = 0 ):
0 commit comments