re.IGNORECASE and re.VERBOSE

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Mon Jul 18 11:20:35 EDT 2005


Jeremy wrote:
> I am using regular expressions and I would like to use both
> re.IGNORECASE and re.VERBOSE options.  I want to do something like the
> following (which doesn't work):
> 
> matsearch = r'''^\ {0,4}([mM]\d+) '''
> MatSearch = re.compile(matsearch, re.VERBOSE, re.IGNORECASE)
> 
> Does anyone have any suggestions?

These flags are combined using the bit-wise OR operator.

re.compile(matsearch, re.VERBOSE|re.IGNORECASE)

Reinhold



More information about the Python-list mailing list