[Tutor] Simple text transform with an RE
Mon, 20 Aug 2001 10:42:25 -0400 (EDT)
On Mon, 20 Aug 2001, Schmidt, Allen J. wrote:
> Hello all...
> I need to learn more about regular expressions. A quick answer to this
> should help...
> I have a text file of database field names - about 90 of them - one on a
> line ended with a line break.
> I need to build something with an RE to read each field from the file, then
> add parts to each field like "ALTER TABLE ADD ....field_name " at the
> beginning and other things to the end of the field name. So, I am trying to
> build a SQL statement from the list of field names. A few have to be changed
> by hand but not a big deal.
REs are _beyond_ overkill for this:
for i in lines:
print 'ALTER TABLE %s ADD changed timestamp' % (t, )
> Also needed...a link to RE examples. Its one thing to read the syntax and
> quite another to gleam actual uses from them. Real world examples really
> help and anything offered would be greatly appreciated.
Online I don't know about. I do know the O'Reilly's book,, _Mastering Regular
Expressions_ is decent, though.
Ignacio Vazquez-Abrams <firstname.lastname@example.org>