By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,759 Members | 1,778 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,759 IT Pros & Developers. It's quick & easy.

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

P: 51
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.
Sep 14 '09 #1
Share this Question
Share on Google+
4 Replies


P: 3
Expand|Select|Wrap|Line Numbers
  1. my $t="hello hello word";
  2. $t=~s/(\b)(\w)/$1\u$2/g;
  3. print $t;
  4.  
Sep 14 '09 #2

P: 51
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
Sep 14 '09 #3

P: 3
perldoc perlre

...
\u uppercase next char (think vi)
...
Sep 14 '09 #4

P: 51
thanks again, i found all i need (and much more) in perlre
Sep 14 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.