Advertisement
rfmonk

re_match.py

Jan 2nd, 2014
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. import re
  5.  
  6. text = 'This is some text -- with punctuation.'
  7. pattern = 'is'
  8.  
  9. print 'Text   :', text
  10. print 'Pattern:', pattern
  11.  
  12. m = re.match(pattern, text)
  13. print 'Match  :', m
  14. s = re.search(pattern, text)
  15. print 'Search :', s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement