Trying to create a formula to turn a string of words separated by spaces into camelcase
It requires only one argument: a text where you want to change the case or a reference to a cell with that text. Once I enter the formula, Google Sheets offers to copy it down for me and capitalize the first letters in all cells: You can either press Ctrl+Enter or click the tick icon to allow spreadsheets to do that.
Much smaller version:
=SUBSTITUTE(PROPER(TRIM(A1))," ","")
We just use PROPER
to upper case and TRIM
and SUBSTITUTE
to remove spaces.
If we want lowerCamelCase,
By just REPLACE
ing the first character with lower case, We have:
=REPLACE(SUBSTITUTE(PROPER(TRIM(A1))," ",),1,1,LEFT(LOWER(TRIM(A1))))
Using REGEX:
=REGEXREPLACE(REGEXREPLACE(PROPER(A1),"\s*",),"^(\w)",LEFT(LOWER(TRIM(A1))))
=LOWER(LEFT(TRIM(A1)))®EXREPLACE(PROPER(TRIM(A1)),"(\w|\s)(\w*)","$2")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With