Given a string, capitalize it. By capitalization I mean conTeNT-lENgth
changes to Content-Length
. In the example I showed the string with 2 words with -
as the word boundary. However I expect you to write the code for the string containing any number of words separated by a single character as the boundary. This boundary may change across the string.
Conditions
- using
regular expressions
is not allowed. - there could be any number of words in a sentence(string).
- each word will consist of
English
letters[a-zA-Z]
of any case. - different words in the sentence will be separated by a single character. This character will only be any one of
-
,.
,/
,&
,#
. You can safely assume that sentence will not contain any other character except the mentioned ones. - word boundaries should be preserved in the output.
- shortest code wins.
For example your program should output Begin/With.Type&Content
for BeGin/wITH.tyPE&conTeNt
.
Some test cases:
"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"
/CC/
in line 2, or-AND&
in line 7) should be left alone. Is this ok, for this challenge? \$\endgroup\$