Case insensitive re.sub()

Timothy Grant tjg at exceptionalminds.com
Tue Feb 20 20:09:35 EST 2001


Thanks Aazh.

That did the trick beautifully. 



On Tue, Feb 20, 2001 at 04:13:44PM -0800, Aahz Maruch wrote:
> In article <mailman.982712484.28722.python-list at python.org>,
> Timothy Grant  <tjg at exceptionalminds.com> wrote:
> >
> >I am working on a little project where it would be really nice
> >to be able to do a case insensitive re.sub(). It appears that
> >re.sub() does not allow a flags argument. Is it possible, or do
> >I have to roll my own?
> 
> import re
> regex = re.compile('foo', re.I)
> print regex.sub('bar','FOOBAR')

-- 
Stand Fast,
    tjg.

Timothy Grant                         tjg at exceptionalminds.com
Red Hat Certified Engineer            www.exceptionalminds.com
Avalon Technology Group, Inc.                   (503) 246-3630
>>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<<
>>>>This machine was last rebooted:  35 days  5:20 hours ago<<




More information about the Python-list mailing list