ucfirst

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kimmo Laine

    ucfirst

    I have abunch of names that I'd like to normalize case-wise. Some are
    lowercase (joe jackson), some uppercase (JOE JACKSON), and some correctly
    cased (Joe Jackson). ucfirst(strtolo wer('JOE JACKSON')); works for most
    cases, but if there's a name with a hyphen, ie. BILLY-BOB JOHNSON and
    jack-bob johnson and Bob-Bob Johnson, they're turned into Billy-bob etc...
    The letter after the hyphen should be uppercased as well, not just the ones
    after space. Anyone got idea how to do this?

    (Then there are names like McGyver or MacCartney and O'Reilly... But that's
    okay, we have so few of this kind of names in Finland it doesn't matter.)

    --
    "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
    http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
    spam@outolempi. net || Gedoon-S @ IRCnet || rot13(xvzzb@bhg byrzcv.arg)


  • BLob

    #2
    Re: ucfirst

    I have abunch of names that I'd like to normalize case-wise. Some are
    lowercase (joe jackson), some uppercase (JOE JACKSON), and some correctly
    cased (Joe Jackson). ucfirst(strtolo wer('JOE JACKSON')); works for most
    cases, but if there's a name with a hyphen, ie. BILLY-BOB JOHNSON and
    jack-bob johnson and Bob-Bob Johnson, they're turned into Billy-bob etc...
    Lucky you if "your" names do not have accents signs (meaning é, è, ê and
    others) ! Otherwise your method wouldn't work, as it would transform
    "STEPHANE" into "Stephane" ("STEPHANE" is correct because capital letters do
    not take accents, whereas "Stephane" should be written "Stéphane") .
    The letter after the hyphen should be uppercased as well, not just the
    ones
    after space. Anyone got idea how to do this?
    A dirty trick :
    Replace "-" by "- ".
    Then do your ucfirst(strtolo wer($name));
    Them replace back "- " by "-".
    That should do it !


    BLob


    Comment

    • Kimmo Laine

      #3
      Re: ucfirst

      "BLob" <blob@nospam.in validwrote in message
      news:44f6fcd3$0 $5098$ba4acef3@ news.orange.fr. ..
      >I have abunch of names that I'd like to normalize case-wise. Some are
      >lowercase (joe jackson), some uppercase (JOE JACKSON), and some correctly
      >cased (Joe Jackson). ucfirst(strtolo wer('JOE JACKSON')); works for most
      >cases, but if there's a name with a hyphen, ie. BILLY-BOB JOHNSON and
      >jack-bob johnson and Bob-Bob Johnson, they're turned into Billy-bob
      >etc...
      >
      Lucky you if "your" names do not have accents signs (meaning é, è, ê and
      others) ! Otherwise your method wouldn't work, as it would transform
      "STEPHANE" into "Stephane" ("STEPHANE" is correct because capital letters
      do
      not take accents, whereas "Stephane" should be written "Stéphane") .
      >
      >The letter after the hyphen should be uppercased as well, not just the
      ones
      >after space. Anyone got idea how to do this?
      >
      A dirty trick :
      Replace "-" by "- ".
      Then do your ucfirst(strtolo wer($name));
      Them replace back "- " by "-".
      That should do it !
      >

      Oh, I never thought of that. How silly, of course that'll work. Good ol'
      dirty hacks. :)

      Thanks BLob

      --
      "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
      http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
      spam@outolempi. net || Gedoon-S @ IRCnet || rot13(xvzzb@bhg byrzcv.arg)


      Comment

      • Kimmo Laine

        #4
        Re: ucfirst

        "Kimmo Laine" <spam@outolempi .netwrote in message
        news:h_AJg.1580 $xC5.86@reader1 .news.jippii.ne t...
        cased (Joe Jackson). ucfirst(strtolo wer('JOE JACKSON')); works for most
        Whoops... Obviously that was supposed to be ucwords :)

        --
        "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
        http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
        spam@outolempi. net || Gedoon-S @ IRCnet || rot13(xvzzb@bhg byrzcv.arg)


        Comment

        Working...