[code.view]

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

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
     #
     """Simple pattern examples.
     """
     #end_pymotw_header
     
     import re
     
     patterns = [ 'this', 'that' ]
     text = 'Does this text match the pattern?'
     
     for pattern in patterns:
         print 'Looking for "%s" in "%s" ->' % (pattern, text),
     
         if re.search(pattern,  text):
             print 'found a match!'
         else:
             print 'no match'
     

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

contact | logmethods.com