I was reading Google's Java Style Guide the other day and stumbled over their algorithm to convert any arbitrary string into camelCase notation. In this challenge you have to implement this algorithm since you don't want to do all this stuff in your head when you are writing your super competitive Java submissions to code-golf challenges.
Note: I made some small adjustments to the algorithm. You need to use the one specified below.
You start with an arbitrary input string and apply the following operations to it:
- Remove all apostrophes
- Split the result into words by splitting at
- characters that are not alphanumerical and not a digit
- Uppercase letters which are surrounded by lowercase letters on both sides.
abcDefGhI jkfor example yields
abc Def Ghi jk
- Lowercase every word.
- Uppercase the first character of every but the first word.
- Join all words back together.
- The input will only contain printable ASCII.
- If a digit is the first letter in a word, leave it as it is and don't capitalize something else in this word.
- The input will always have at least one character.
- Function or full program allowed.
- Default rules for input/output.
- Standard loopholes apply.
- This is code-golf, so lowest byte-count wins. Tiebreaker is earlier submission.
"Programming Puzzles & Code Golf" -> "programmingPuzzlesCodeGolf" "XML HTTP request" -> "xmlHttpRequest" "supports IPv6 on iOS?" -> "supportsIpv6OnIos" "SomeThing w1th, apo'strophe's and' punc]tuation" -> "someThingW1thApostrophesAndPuncTuation" "nothing special" -> "nothingSpecial" "5pecial ca5e" -> "5pecialCa5e" "1337" -> "1337" "1337-spEAk" -> "1337Speak" "whatA mess" -> "whataMess" "abcD" -> "abcd" "a" -> "a" "B" -> "b"