[Python-checkins] CVS: python/dist/src/Lib sre.py,1.42,1.43

Fredrik Lundh effbot@users.sourceforge.net
Wed, 24 Oct 2001 15:16:32 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv10490/Lib

Modified Files:
	sre.py 
Log Message:


(experimental) "finditer" method/function.  this works pretty much
like findall, but returns an iterator (which returns match objects)
instead of a list of strings/tuples.


Index: sre.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** sre.py	2001/10/21 21:48:30	1.42
--- sre.py	2001/10/24 22:16:30	1.43
***************
*** 94,97 ****
--- 94,98 ----
  """
  
+ import sys
  import sre_compile
  import sre_parse
***************
*** 164,167 ****
--- 165,177 ----
      Empty matches are included in the result."""
      return _compile(pattern, 0).findall(string)
+ 
+ if sys.hexversion >= 0x02020000:
+     def finditer(pattern, string):
+         """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)
  
  def compile(pattern, flags=0):