Bieżące odpowiedzi są w porządku, ale jeśli pracujesz z ciągami w kodzie, możesz użyć biblioteki manipulacji ciągami s
. s-capitalize
kapitalizuje pierwsze słowo w zdaniu.
ELISP> (s-capitalize "can't win the war on drugs in a prison, where the hell you gonna win it?")
"Can't win the war on drugs in a prison, where the hell you gonna win it?"
ELISP> (s-join " " (-map 's-capitalize (s-split " " "can't win the war on drugs in a prison, where the hell you gonna win it?")))
"Can't Win The War On Drugs In A Prison, Where The Hell You Gonna Win It?"
s-titleize
aktywuje każde słowo w ciąg, ale jest to proste otoki wokół wbudowanej capitalize
, dlatego stosuje Karl Voigtland's workaround.
ELISP> (s-titleize "Girl, you can't even think of calling this shit a war.")
"Girl, You Can'T Even Think Of Calling This Shit A War."
ELISP> (progn (modify-syntax-entry ?' "w") (s-titleize "Girl, you can't even think of calling this shit a war."))
"Girl, You Can't Even Think Of Calling This Shit A War."
+1, jedna uwaga z tym jednak: (zamień "to jest" test "") "To jest test" " – cobbal