Advertisement
rfmonk

re_finditer.py

Dec 30th, 2013
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.21 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import re
  4.  
  5. text = 'abbaaabbbbaaaaa'
  6.  
  7. pattern = 'ab'
  8.  
  9. for match in re.finditer(pattern, text):
  10.     s = match.start()
  11.     e = match.end()
  12.     print 'Found "%s" at %d:%d' % (text[s:e], s, e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement