function toCamelCase(str) {
// Convert the entire string to lowercase
return str.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, function(match, group1) {
// For each match, convert the first character of the match to uppercase
return group1.toUpperCase();
}).replace(/^[^a-zA-Z0-9]+/g, ''); // Remove any non-alphanumeric characters from the beginning of the string
}
I have been trying this code. But the problem is if the provided string is with a number or has any other character that should be removed. I couldn't build this logic. Can anyone explain how can i do this? [tag:I have seen some solution but that can not filter the number.]