[code.view]

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

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
     #
     """Embedding flags in the expression.
     """
     #end_pymotw_header
     
     import re
     
     text = 'This is some text -- with punctuation.'
     pattern = r'(?i)\bT\w+'
     regex = re.compile(pattern)
     
     print 'Text      :', text
     print 'Pattern   :', pattern
     print 'Matches   :', regex.findall(text)
     
     

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

contact | logmethods.com