Converting to title case
jhurley0305 at sbcglobal.net
Thu Aug 26 15:18:41 CDT 2010
> Message: 3
> Date: Wed, 25 Aug 2010 15:44:01 -0300
> From: Andre Garzia <andre at andregarzia.com>
> Subject: Re: Converting to title case
> To: How to use Revolution <use-revolution at lists.runrev.com>
> <AANLkTikm63Ci3PKLtP9Qu57gfbb4O99aaHM1TmzDSXOt at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
> why not this:
> put fld "list" into tContent
> repeat for each word tName in tContent
> replace tName with (toUpper(char 1 of tName) & toLower(char 2 to -1
> end repeat
> This will capitalize all your names right?
> http://www.andregarzia.com All We Do Is Code.
Thanks for your suggestion. An interesting alternative.
But don't forget the "container" at the end of the "replace" command.
If the container is tContent there will be considerable overlap.
For example, if tName is say "Auburn," a city in our county, and there
were 1,000 instances of that word (since this is an election DB there
will be thousands of instances of each city in the county) you will be
replacing 1000 instance of "auburn" with "Auburn" and doing so 1000
times. That is 1,000,000 replacements--most of them of course will be
substituting "Auburn" for "Auburn."
What one could do is build a dictionary of the DB and then replace
each incidence of each word from the dictionary. The advantage of this
would be that there would be no danger of overlooking a white space
that i hadn't recognized. But the down side is that it is VERY slow.
I waited an hour and it hadn't finished.
On the other hand, running through each character, even through there
are 26,631,931 of them, takes only about 40 seconds on my very slow
Mac Mini. But I only have to do it once for each new release of the
election DB, so I have no incentive to optimize the script. My only
worry, as I said, was that I hadn't overlooked some white spaces
besides tab, space, enter and return.
More information about the use-livecode