#!/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)