Re: [Tutor] re.sub() query

2010-06-20 Thread Mark Lawrence
On 20/06/2010 10:54, Payal wrote: Hi, Is it possible to solve the below, w/o making a re object? a 'Mary Had a Little Lamb' p=re.compile('l',re.I) re.sub(p,'-',a) 'Mary Had a -itt-e -amb' I cannot figure how to se re.I w/o involving p. Thanks. With warm regards, -Payal You can do this.

Re: [Tutor] re.sub() query

2010-06-20 Thread Payal
On Sun, Jun 20, 2010 at 12:03:47PM +0200, Evert Rol wrote: > >>> re.sub('(?i)l', '-', a) > > See http://docs.python.org/library/re.html#regular-expression-syntax , search > for iLmsux, which provide flags inside the regex. Goodness that was fast. Thanks a lot Evert. For records, >>> re.sub('l(

Re: [Tutor] re.sub() query

2010-06-20 Thread Evert Rol
> Is it possible to solve the below, w/o making a re object? > a > 'Mary Had a Little Lamb' p=re.compile('l',re.I) re.sub(p,'-',a) > 'Mary Had a -itt-e -amb' > > I cannot figure how to se re.I w/o involving p. Would this work? >>> re.sub('(?i)l', '-', a) See http://docs.python.o

[Tutor] re.sub() query

2010-06-20 Thread Payal
Hi, Is it possible to solve the below, w/o making a re object? >>> a 'Mary Had a Little Lamb' >>> p=re.compile('l',re.I) >>> re.sub(p,'-',a) 'Mary Had a -itt-e -amb' I cannot figure how to se re.I w/o involving p. Thanks. With warm regards, -Payal --