Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import re
- pattern = 'this'
- text = 'Does this text match the pattern?'
- match = re.search(pattern, text)
- s = match.start()
- e = match.end()
- print 'Found "%s"\nin "%s"\from %d to %d ("%s")' % \
- (match.re.pattern, match.string, s, e, text[s:e])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement