文字列がキャメルケースかどうか(ブール値)を確認したいのですが。私は正規表現を使用する傾向がありますが、他のエレガントなソリューションならどれでも機能します。簡単な正規表現を書きました
(?:[A-Z])(?:[a-z])+(?:[A-Z])(?:[a-z])+
これは正しいでしょうか?それとも私は何かが足りないのですか?
編集
この形式のテキストドキュメントのコレクションに名前をキャプチャしたい
McDowell
O'Connor
T.Kasting
Edit2
コメントの提案に基づいて正規表現を変更しました
(?:[A-Z])(?:\S?)+(?:[A-Z])(?:[a-z])+