diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2009-03-02 05:21:55 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2009-03-02 05:21:55 (GMT) |
commit | ccc5ae7ae13138eb3acf3a15e92983a49e53dd90 (patch) | |
tree | ec15b883a13aa8ee8cfcfdcf0e633e83ec236422 /Lib/re.py | |
parent | 4221c74cb00fa00ce8b4a6015c59a233246bf1e9 (diff) | |
download | cpython-ccc5ae7ae13138eb3acf3a15e92983a49e53dd90.zip cpython-ccc5ae7ae13138eb3acf3a15e92983a49e53dd90.tar.gz cpython-ccc5ae7ae13138eb3acf3a15e92983a49e53dd90.tar.bz2 |
Merged revisions 70090 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70090 | gregory.p.smith | 2009-03-01 21:13:57 -0800 (Sun, 01 Mar 2009) | 3 lines
Adds an optional flags argument to re.split, re.sub and re.subn to be
consistent with the other re module functions.
........
Diffstat (limited to 'Lib/re.py')
-rw-r--r-- | Lib/re.py | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -156,16 +156,16 @@ def search(pattern, string, flags=0): a match object, or None if no match was found.""" return _compile(pattern, flags).search(string) -def sub(pattern, repl, string, count=0): +def sub(pattern, repl, string, count=0, flags=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 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) + return _compile(pattern, flags).sub(repl, string, count) -def subn(pattern, repl, string, count=0): +def subn(pattern, repl, string, count=0, flags=0): """Return a 2-tuple containing (new_string, number). new_string is the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in the source @@ -174,12 +174,12 @@ def subn(pattern, repl, string, count=0): 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) + return _compile(pattern, flags).subn(repl, string, count) -def split(pattern, string, maxsplit=0): +def split(pattern, string, maxsplit=0, flags=0): """Split the source string by the occurrences of the pattern, returning a list containing the resulting substrings.""" - return _compile(pattern, 0).split(string, maxsplit) + return _compile(pattern, flags).split(string, maxsplit) def findall(pattern, string, flags=0): """Return a list of all non-overlapping matches in the string. |