Hey everyone! I’m trying to figure out how to make a function in Google Sheets that changes text with spaces into lowerCamelCase. For example, I want to turn ‘hello world example’ into ‘helloWorldExample’.
I’ve seen some stuff about regular CamelCase, but I’m not sure how to make it work for lowerCamelCase. Does anyone have any ideas or tricks they’ve used before? I’m not great with formulas, so any help would be awesome!
Here’s a simple example of what I’m trying to do:
function toLowerCamelCase(input) {
// Need help here!
return output;
}
// Should return 'helloWorldExample'
toLowerCamelCase('hello world example');
I’ve tackled this problem before in Google Sheets. Here’s a custom function that should do the trick:
function toLowerCamelCase(input) {
var words = input.toLowerCase().split(' ');
var result = words[0];
for (var i = 1; i < words.length; i++) {
result += words[i].charAt(0).toUpperCase() + words[i].slice(1);
}
return result;
}
This function first converts the input to lowercase and splits it into words. It keeps the first word as-is, then capitalizes the first letter of each subsequent word and adds it to the result. You can use this in your spreadsheet by calling =toLowerCamelCase(A1) where A1 contains your input text. Hope this helps!
Here’s how it works:
LOWER(LEFT(A1,1)) keeps the first letter lowercase.
PROPER(A1) capitalizes the first letter of each word.
REGEXREPLACE removes all spaces.
Just pop this into a cell next to your original text, and it’ll automatically convert it to lowerCamelCase. It’s been a real time-saver for me, especially when dealing with large datasets. No custom functions needed!
it’s pretty sweet. just chuck ur text in A1 and boom, lowerCamelCase magic happens. no need for fancy scripts or nuthin. lemme know if it works for ya!