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 = r'\bT\w+'
- with_case = re.compile(pattern)
- without_case = re.compile(pattern, re.IGNORECASE)
- print 'Text:\n %r' % text
- print 'Pattern:\n %s' % pattern
- print 'Case-sensitive:'
- for match in with_case.findall(text):
- print ' %r' % match
- print 'Case-insensitive:'
- for match in without_case.findall(text):
- print ' %r' % match
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement