|
|
Subject:
How to capitalize the first letter of each word in PERL
Category: Computers > Programming Asked by: yt_nitram-ga List Price: $5.00 |
Posted:
09 Jul 2005 12:17 PDT
Expires: 15 Jul 2005 13:31 PDT Question ID: 541585 |
I have a search engine script written in Perl/CGI, and most of the users input their query "all lowercase". I want to know the line(s) of Perl code require to automatically capitalize the first letter of each word the user inputs: "Uppercase". Examples: $query = televisions becomes... $query = Televisions $query = stock market becomes... $query = Stock Market THANKS! |
|
There is no answer at this time. |
|
Subject:
Re: How to capitalize the first letter of each word in PERL
From: bozo99-ga on 09 Jul 2005 13:16 PDT |
@words=split(/\s+/); for ($i=0;($i<@words);$i++) { if ($words[$i] =~ /([a-z])(.*)/) { $words[$i]= (uc $1) . $2; } } $text=join(" ",@words); printf("MixedCase: %s\n", $text); |
Subject:
Re: How to capitalize the first letter of each word in PERL
From: vladimir-ga on 10 Jul 2005 13:53 PDT |
$query =~ s/\b(\w)/\u$1/g; |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |