This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Initcap of a string

 
Gitanjali Magani
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i get the initcap of a string?

ex: convert "search again" to "Search Again"


thanks,
gita
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no trivial, built-in-to-the-API way to do it.

With a bit of care, you could do it all at once with a regular expression, or you could do it by looping over the characters in a String, appending them to a StringBuffer, capitalizing each letter than follows whitespace.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic