Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: [string totitle "ab cd ef"] does not output "Ab Cd Ef" but instead "Ab
Bruce Hartweg <bruce-news@hartweg.us> wrote in message news:<%gyXc.322037$%_
6.194545@attbi_s01>...

> you need/want something that is parsing the string into words and operatin
g
> on them individually. You could do this with a regsub/subst pair ...
>
> proc multiWordTitleCase {str} {
>    subst [regsub -all {\w+} $str {[string totitle "&"]}]
> }
>
> Bruce

Isn't this code faster and more accurate:

proc wordsToTitle {str} {
foreach word $str {lappend output [string totitle $word]}
return $output
}

On tcl/tk 8.4.6.1 on win2k:

(bin) 62 % set test "it's a test"
it's a test
(bin) 63 % multiWordTitleCase $test
It'S A Test
(bin) 64 % wordsToTitle $test
It's A Test
(bin) 65 % time {multiWordTitleCase $test} 10000
55 microseconds per iteration
(bin) 66 % time {wordsToTitle $test} 10000
10 microseconds per iteration

--
Gilbert van Griensven

Report this thread to moderator Post Follow-up to this message
Old Post
Jules
08-27-04 01:58 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Tcl archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:49 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.