I have the following code that works in Python 2.7:
entry_regex = '(' + search_string + ')'
entry_split = re.split(entry_regex, row, 1, re.IGNORECASE)
I need to make it work in Python 2.6 as well as in Python 2.7 and 2.6 re.split doesn't accept a flag (re.IGNORECASE) as forth parameter. Any help? Thanks
You can just add (?i) to the regular expression to make it case insensitive:
>>> import re
>>> reg = "(foo)(?i)"
>>> re.split(reg, "fOO1foo2FOO3")
['', 'fOO', '1', 'foo', '2', 'FOO', '3']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With