tags:

views:

55

answers:

2

how do i set the regular expressions flags like multiline and ignorecase in python 2.3?

in python 2.6 its like this

re.findall(pattern,string, re.multiline | re.ignorecase)

but this doesn't seem to wok for python 2.3, any ideas?

pointers appreciated

edit: sorry, it was python 2.3 not 2.4

+1  A: 

Compile the regexp in advance with re.compile(pattern[, flags]). Then you can pass the options as the second parameter.

Aaron Digulla
it worked thanks
burlsm
+1  A: 

the flags are uppercase in 2.4, e.g.:

re.findall(pattern,string, re.MULTILINE | re.IGNORECASE)

works for me;

Python 2.4.3 (#1, Sep  3 2009, 15:37:37) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.findall("Test","Test\ntest\nTEST",re.MULTILINE|re.IGNORECASE)
['Test', 'test', 'TEST']
Kimvais
+1, works fine on 2.3 ad well
orip
hmm, figured out Aaron was right.
orip