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 converted to uppercase. Note that the > second "select" string is not a keyword and thus I do not want to > convert it to uppercase. Thus, I don't think the string.replace() > method will work for me. > [snip]
FYI, yhe replace method can take a third argument, which is the maximum number of replacements to do: >>> query = "select column1, 'select' as type from table where column2 = 'foo'" >>> query.replace("select", "SELECT", 1) "SELECT column1, 'select' as type from table where column2 = 'foo'" -- http://mail.python.org/mailman/listinfo/python-list