私は、タイトルケースに変更する必要があるタイトルのリストを含むテキストファイルを持っています(単語は大文字、大文字、前置詞以外の大文字で始まる必要があります)。テキストを大文字に変換するにはどうすればよいですか?
例えば、本のタイトルのリスト:
barbarians at the gate
hot, flat, and crowded
A DAY LATE AND A DOLLAR SHORT
THE HITCHHIKER'S GUIDE TO THE GALAXY
は、次のように変更します。
Barbarians at the Gate
Hot, Flat, and Crowded
A Day Late and a Dollar Short
The Hitchhiker's Guide to the Galaxy
私は、次のコードを書いた:
while(<DATA>)
{
$_=~s/(\s+)([a-z])/$1.uc($2)/eg;
print $_;
}
をしかし、それは最初を大文字タイトルの真ん中にある "at"、 "the"、 "a"のようなすべての単語の文字:
Barbarians At The Gate
Hot, Flat, And Crowded
A Day Late And A Dollar Short
The Hitchhiker's Guide To The Galaxy
どうすればいいですか?
も参照してください[Lingua :: EN :: Titlecase](https://metacpan.org/pod/Lingua::EN::Titlecase) –
@HåkonHægland:Awesome私たちはそれを得た。 – ssr1012