Re: re.sub and re.MULTILINE

2007-01-09 Thread nyenyec
Paddy wrote: > Check the arguments to re.sub. > > >>> re.sub('(?m)^foo', 'bar', '\nfoo', count=0) > '\nbar' > > - Paddy. Duh! :) I appreciate it, thanks. -- nyenyec -- http://mail.python.org/mailman/listinfo/python-list

Re: re.sub and re.MULTILINE

2007-01-08 Thread Paddy
nyenyec wrote: > I feel like a complete idiot but I can't figure out why re.sub won't > match multiline strings: > > This works: > >>> re.search("^foo", "\nfoo", re.MULTILINE) > <_sre.SRE_Match object at 0x6c448> > > This doesn't. No replacement: > >>> re.sub("^foo", "bar", "\nfoo", re.MULTILINE)

re.sub and re.MULTILINE

2007-01-08 Thread nyenyec
I feel like a complete idiot but I can't figure out why re.sub won't match multiline strings: This works: >>> re.search("^foo", "\nfoo", re.MULTILINE) <_sre.SRE_Match object at 0x6c448> This doesn't. No replacement: >>> re.sub("^foo", "bar", "\nfoo", re.MULTILINE) '\nfoo' Why? Thanks, nyenyec

re.sub and re.MULTILINE

2007-01-08 Thread nyenyec
I feel like a complete idiot but I can't figure out why re.sub won't match multiline strings: This works: >>> re.search("^foo", "\nfoo", re.MULTILINE) <_sre.SRE_Match object at 0x6c448> This doesn't. No replacement: >>> re.sub("^foo", "bar", "\nfoo", re.MULTILINE) '\nfoo' Why? Thanks, nyenyec