Re: Python equivalent of Perl e flag with regular expression

2008-10-03 Thread MRAB
On Oct 2, 6:06 pm, "Friedman, Jason" <[EMAIL PROTECTED]> wrote: > I have lines that look like this: > select column1, 'select' as type > from table > where column2 = 'foo' > > I want to return: > SELECT column1, 'select' AS type > FROM table > WHERE column2 = 'foo' > > This is SQL with the keywords

Re: Python equivalent of Perl e flag with regular expression

2008-10-02 Thread Mark Thomas
On Oct 2, 4:03 pm, [EMAIL PROTECTED] wrote: >     Jason> With Perl I might do something like this: >     Jason> $line =~ s/(select)/uc($1)/e; >     ... >     Jason> How would I do this with Python? > > I'm sure there are plenty of ways to skin this particular cat, but how is > 's/.../.../e' differe

Re: Python equivalent of Perl e flag with regular expression

2008-10-02 Thread skip
Jason> With Perl I might do something like this: Jason> $line =~ s/(select)/uc($1)/e; ... Jason> How would I do this with Python? I'm sure there are plenty of ways to skin this particular cat, but how is 's/.../.../e' different from 's/.../.../'? (For those of us who are not Perl

Re: Python equivalent of Perl e flag with regular expression

2008-10-02 Thread George Sakkis
On Oct 2, 1:06 pm, "Friedman, Jason" <[EMAIL PROTECTED]> wrote: > I have lines that look like this: > select column1, 'select' as type > from table > where column2 = 'foo' > > I want to return: > SELECT column1, 'select' AS type > FROM table > WHERE column2 = 'foo' > > This is SQL with the keywords

Re: Python equivalent of Perl e flag with regular expression

2008-10-02 Thread Peter Otten
Friedman, Jason wrote: > I have lines that look like this: > select column1, 'select' as type > from table > where column2 = 'foo' > > I want to return: > SELECT column1, 'select' AS type > FROM table > WHERE column2 = 'foo' > > This is SQL with the keywords converted to uppercase. Note that th