how to replace each first letter of a word into capital letter :

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zcabeli
    New Member
    • Jan 2008
    • 51

    how to replace each first letter of a word into capital letter :

    Hi all, i'm currently struggling to perform the above mentioned replacement.

    i already know how to catch the first letter in each word and determined if it's regular or capital.

    however, i don't know how to replace this letter with it's corresponding capital letter.

    perhaps there is an option to change the ascii value of the a character in perl regexp ?

    for example :

    Hello hello word --> Hello Hello World

    many thanks for your help.
  • RichKersh
    New Member
    • Sep 2009
    • 3

    #2
    Code:
    my $t="hello hello word";
    $t=~s/(\b)(\w)/$1\u$2/g;
    print $t;

    Comment

    • zcabeli
      New Member
      • Jan 2008
      • 51

      #3
      hey, thanks for the help ! i really appreciate it.
      can you explain what does the '\u' symbol means, i haven't found it in any perl documentation

      Comment

      • RichKersh
        New Member
        • Sep 2009
        • 3

        #4
        perldoc perlre

        ...
        \u uppercase next char (think vi)
        ...

        Comment

        • zcabeli
          New Member
          • Jan 2008
          • 51

          #5
          thanks again, i found all i need (and much more) in perlre

          Comment

          Working...