[code.view]

[top] / python / PyMOTW / re / re_match.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
     #
     """Matching vs. searching
     """
     #end_pymotw_header
     
     import re
     
     text = 'This is some text -- with punctuation.'
     pattern = 'is'
     
     print 'Text   :', text
     print 'Pattern:', pattern
     
     m = re.match(pattern, text)
     print 'Match  :', m
     s = re.search(pattern, text)
     print 'Search :', s
     

[top] / python / PyMOTW / re / re_match.py

contact | logmethods.com