`
const camelize = (str) => {
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) => {
return index === 0 ? word.toLowerCase() : word.toUpperCase();
}).replace(/\s+/g, '');
}
console.log(camelize("EquipmentClass name"));
`
public static string Camelize(string str) {
return Regex.Replace(str, @"(?:^\w|[A-Z]|\b\w)", (Match match) => {
return match.Index == 0 ? match.Value.ToLower() : match.Value.ToUpper();
}).Replace(" ", "");
}
好吧,搜索空格,如果找到一个,获取下一个字符并尝试将其大写