[Python-checkins] python/dist/src/Lib sre.py,1.50,1.51

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Fri Sep 24 05:41:07 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24976/lib

Modified Files:
	sre.py 
Log Message:
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().



Index: sre.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- sre.py	25 Aug 2004 02:22:29 -0000	1.50
+++ sre.py	24 Sep 2004 03:41:05 -0000	1.51
@@ -156,7 +156,7 @@
     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 @@
     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."



More information about the Python-checkins mailing list