Insert characters into string based on re ?

guido.thelen at googlemail.com guido.thelen at googlemail.com
Thu Oct 19 23:47:17 CEST 2006


Hi,
initially I had the same idea before I started writing a SQL Formatter.
I was sure that coding a few "change" commands in a script would
reformat my SQL statements. But step by step I recognized that SQL
statements can not be formatted by regular expressions. Why not?
Because there is a risk that you change e.g. values in literals and
this is changing the result of a query!!
Example:

--> Select pieces where status like "Join with master piece"

Inserting line-breaks before joins using a "change" command would
change the SQL statement into

--> Select pieces where status like "\nJoin with master piece"

The new select statement is no more working in the same way as the
original one.

In the meantime, the "script" has about 80 pages of code .....

Regards
GuidoMarcel




More information about the Python-list mailing list