re.IGNORECASE and re.VERBOSE

J

Jeremy

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?
Thanks,
Jeremy
 
R

Reinhold Birkenfeld

Jeremy said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top