Capitalize String

Python 3,22

print(input().title())

This code will take a string as input from stdin and gives a capitalized output to stdout.

for example:

input:

BEGIN/wITH.tyPe&cOnTENt

ouput:

Begin/With.Type&Content

The following code is for multi-line inputs (if necessary)

Python 3, 46

import sys
for i in sys.stdin:print(i.title())

GolfScript, 36 27 19 characters

0\{95&+.47>32*\}%\;

A quite basic GolfScript approach which works for all input according to the specification. The examples can be tested online.


Mathematica 62

Data

tests={"aGeNT ACcEpT/LEngTh-tYPe USeR raNgE.TyPe","type&AgeNt/CC/COnteNt lEnGth#acCePT/AgeNt.RAnGe-Cc/contEnt/cODe","cc/rEspoNCe.lEngtH#tYpEwitH&UsEr/bEgIN&uSer.AGEnT&begIn/aCCEPt/Cc","lENgTH#USeR.tYpE/BeGiN&LENGth tYpe/ACCEpt#rANge/codE&AnD-ACCepT/ConTenT","contENT/ACcEpT","BeGin/wITH.tyPE&conTeNt","Code.cc#User.lenGTh-USer-AND&tyPE TypE&leNgtH.tYPe usER.UseR&with","RaNgE&COnTeNT WITh CoNTENT-TypE tyPe","BEgin COdE#uSeR#aGeNt.USeR","TypE LENGth"}

Code

StringReplace[ToLowerCase@#,WordBoundary~~x_:>ToUpperCase@x]&

Usage

f["aGeNT ACcEpT/LEngTh-tYPe USeR raNgE.TyPe"]

"Agent Accept/Length-Type User Range.Type"

f /@ tests

{"Agent Accept/Length-Type User Range.Type",
"Type&Agent/Cc/Content Length#Accept/Agent.Range-Cc/Content/Code", "Cc/Responce.Length#Type-With&User/Begin&User.Agent&Begin/Accept/Cc", "Length#User.Type/Begin&Length Type/Accept#Range/Code&And-Accept/Content", "Content/Accept",
"Begin/With.Type&Content",
"Code.Cc#User.Length-User-And&Type Type&Length.Type User.User&With",
"Range&Content With Content-Type Type",
"Begin Code#User#Agent.User",
"Type Length"}