[TxMt] Re: How to target specific fields for a "Change to Titlecase" in SQL

Alex Ross tm-alex at rosiba.com
Mon Aug 11 23:55:22 UTC 2008


> I'm working on a custom Textpattern installation and my client has
> entered a massive amount of text data in certain fields using
> UPPERCASE. He wants the text displayed in Title Case instead, and he
> doesn’t want to manually change it. I can easily use the style
> declaration "text-transform: capitalize;" for these elements, but my
> client would very much prefer formal title case in which words such
> as “the,” “of,” “and,” and “for” are not capitalized. (I see that
> Textmate’s "Convert to Titlecase" command in the "Text" menu does
> this correctly.)
>
> I have made a mysql dump of the database, but I'm not sure how to
> isolate the appropriate data for a text transformation. Here is how
> each individual record is formatted in the database:
>
> (91,'2008-08-03 05:20:57','author-username','2008-08-03
> 05:26:33','','UPPERCASE DATA','','','','','','','UPPERCASE-DATA','',
> 0,'Comment',0,4,1,1,'section-name','','lowercase-data','lowercase-
> data','','','','','','','','','','','UPPERCASE DATA','','lowercase-
> data','3p344629nn178n874sp2s222s0q3n072','2008-08-03')
>
> The mysql dump also contains uppercase terms such as "DROP TABLE IF
> EXISTS" and lowercase terms like "datetime" and "varchar" that I
> _don't_ want changed. Is there a simple way to target just the
> UPPERCASE DATA fields enclosed in single quotes for a massive "Covert
> to Titlecase"?

My suggestion would be to write a script that pipes the offending  
fields through John Gruber's TitleCase.pl script and updates the table.

He has posted it here: http://daringfireball.net/2008/05/title_case

—Alex


More information about the textmate mailing list