diff options
author | Raymond Hettinger <python@rcn.com> | 2004-09-24 03:41:05 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-09-24 03:41:05 (GMT) |
commit | 596ba4d89e139efbac86a3254aa1d3653f1382ee (patch) | |
tree | 05bfa5a04952924b6f5269e3737221b3e0383eb2 /Lib/sre.py | |
parent | 9fa544cfa3a8f124fa4e88481ba0b60406e0caed (diff) | |
download | cpython-596ba4d89e139efbac86a3254aa1d3653f1382ee.zip cpython-596ba4d89e139efbac86a3254aa1d3653f1382ee.tar.gz cpython-596ba4d89e139efbac86a3254aa1d3653f1382ee.tar.bz2 |
Granted Noam Raphael's request for minor improvements to the re module and
its documentation.
* Documented that the compiled re methods are supposed to be more full
featured than their simpilified function counterparts.
* Documented the existing start and stop position arguments for the
findall() and finditer() methods of compiled regular expression objects.
* Added an optional flags argument to the re.findall() and re.finditer()
functions. This aligns their API with that for re.search() and
re.match().
Diffstat (limited to 'Lib/sre.py')
-rw-r--r-- | Lib/sre.py | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -156,7 +156,7 @@ def split(pattern, string, maxsplit=0): returning a list containing the resulting substrings.""" return _compile(pattern, 0).split(string, maxsplit) -def findall(pattern, string): +def findall(pattern, string, flags=0): """Return a list of all non-overlapping matches in the string. If one or more groups are present in the pattern, return a @@ -164,16 +164,16 @@ def findall(pattern, string): has more than one group. Empty matches are included in the result.""" - return _compile(pattern, 0).findall(string) + return _compile(pattern, flags).findall(string) if sys.hexversion >= 0x02020000: __all__.append("finditer") - def finditer(pattern, string): + def finditer(pattern, string, flags=0): """Return an iterator over all non-overlapping matches in the string. For each match, the iterator returns a match object. Empty matches are included in the result.""" - return _compile(pattern, 0).finditer(string) + return _compile(pattern, flags).finditer(string) def compile(pattern, flags=0): "Compile a regular expression pattern, returning a pattern object." |