capitalize only when 4 or more letters are caps

Discussion in 'Ruby' started by Chris G., Jul 1, 2008.

  1. Chris G.

    Chris G. Guest

    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/.
     
    Chris G., Jul 1, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mikael Petterson

    xsl syntax to generate all caps with _

    Mikael Petterson, Sep 10, 2003, in forum: XML
    Replies:
    3
    Views:
    949
    Dimitre Novatchev
    Sep 11, 2003
  2. Merrigan
    Replies:
    4
    Views:
    606
    Chris
    Dec 14, 2007
  3. Iñaki Baz Castillo

    "capitalize" also letters after "-" ?

    Iñaki Baz Castillo, May 10, 2008, in forum: Ruby
    Replies:
    3
    Views:
    109
    Iñaki Baz Castillo
    May 10, 2008
  4. Iñaki Baz Castillo

    String#capitalize more complex

    Iñaki Baz Castillo, Apr 2, 2009, in forum: Ruby
    Replies:
    5
    Views:
    143
    Iñaki Baz Castillo
    Apr 2, 2009
  5. Venugopal
    Replies:
    11
    Views:
    1,671
    Tassilo v. Parseval
    Nov 5, 2003
Loading...

Share This Page