[code.view]

[top] / python / PyMOTW / re / re_finditer.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
     #
     """Repetition of patterns
     """
     #end_pymotw_header
     
     import re
     
     text = 'abbaaabbbbaaaaa'
     
     pattern = 'ab'
     
     for match in re.finditer(pattern, text):
         s = match.start()
         e = match.end()
         print 'Found "%s" at %d:%d' % (text[s:e], s, e)
     

[top] / python / PyMOTW / re / re_finditer.py

contact | logmethods.com