Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import re
- text = 'This is some text -- with punctuation.'
- pattern = re.compile(r'\b\w*is\w*\b')
- print 'Text:', text
- print
- pos = 0
- while True:
- match = pattern.search(text, pos)
- if not match:
- break
- s = match.start()
- e = match.end()
- print ' %2d : %2d = "%s"' % \
- (s, e - 1, text[s:e])
- # move forward in text for the next search
- pos = e
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement