46410Re: Quickest way to lowercase all characters in a file EXCEPT those in single quotes?
- Jan 2, 2004On Fri, Jan 02, 2004 at 07:27:47AM -0800, Dennis W. Disney wrote:
> I asked earlier what is the quickest way to lowercase all characters inIf you want help with that, provide a more complete description of
> a file EXPECT those in single quotes. Let me provide a bit more
> background - I am trying to write something to reformat SQL generated
> by a reporting tool. It generates SQL that looks like:
> ( PRODUCT.PRODUCT_ID=SALES.PRODUCT_ID )
> AND ( STORE.STORE_ID=SALES.STORE_ID )
> AND ( PRODUCT.CATEGORY='BEER' )
> GROUP BY
> And I want to reformat the SQL to look like:
> SELECT product.product_name,
> FROM product,
> WHERE product.product_id=sales.product_id
> AND store.store_id=sales.store_id
> AND product.category='BEER'
> GROUP BY product.product_name,
> My plan is to convert everything that is not between a pair of single
> quotes into lowercase, then change all of the SQL keywords into
> uppercase. Next, remove the pointless parenthesis in the WHERE and AND
> lines. Then, go through the file to get the words lined up as I like.
> I was going to do this as a plug in, but I couldn't get the plugin to
> use the \< and \> atoms, which I need to find the SQL keywords. Now, I
> plan on writing a script file and executing that.
> Back to the initial problem of putting everything in lowercase[snip]
> characters EXCEPT those in single quotes. Benji Fisher suggested:
> Roberto Bonvallet suggested:[snip]
If you want to do this from a script, I suggest that you do not use
macros, as in the snipped suggestions. Is it safe to assume that
strings are always on the same line, or do we have to worry about
'strings that span
multiple lines, like this'?
In your example, the original file is ALL CAPS. Is it safe to
assume this, or may there be strings with 'mIxEd CaPs' that you want to
- << Previous post in topic Next post in topic >>