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.'
- print 'Input text :', text
- # word starting with 't' then another word
- regex = re.compile(r' (\bt\w+)\W+(w+)')
- print 'Pattern :', regex.pattern
- match = regex.search(text)
- print 'Entire match :', match.group(0)
- print 'Word starting with "t":', match.group(1)
- print 'Word after "t" word :', match.group(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement