ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
capitalize only when 4 or more letters are caps
by Chris G. other posts by this author
Jul 1 2008 12:19PM messages near this date
Re: [ANN] threadify-0.0.1 | Re: capitalize only when 4 or more letters are caps
I have a chunk of text that could be sentences. If someone types in all
caps, I would like to use capitalize on  just the words that are in all
caps. If I just use it on the entire object, my sentences get messed up
and don't start with a capital letter like they should.

I was wondering what an easy solution might be. I figured I could break
the string apart at the spaces to get the words easily enough, but what
about the conditional to only use capitalize on words with 4 or more
capital letters. That part has me stumped. I think I need a regular
expression for it, but I'm not sure what it should be.

Surely I am not the first person to want to do this.
-- 
Posted via http://www.ruby-forum.com/.
Thread:
Chris G.
Dana Merrick

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved