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 string, backslash escapes in it are processed. If it is a callable, it's passed the Match object an
(pattern, repl, string, count=0, flags=0)
| 176 | return _compile(pattern, flags).search(string) |
| 177 | |
| 178 | def sub(pattern, repl, string, count=0, flags=0): |
| 179 | """Return the string obtained by replacing the leftmost |
| 180 | non-overlapping occurrences of the pattern in string by the |
| 181 | replacement repl. repl can be either a string or a callable; |
| 182 | if a string, backslash escapes in it are processed. If it is |
| 183 | a callable, it's passed the Match object and must return |
| 184 | a replacement string to be used.""" |
| 185 | return _compile(pattern, flags).sub(repl, string, count) |
| 186 | |
| 187 | def subn(pattern, repl, string, count=0, flags=0): |
| 188 | """Return a 2-tuple containing (new_string, number). |