jjzjj

happyCamelize

全部标签

javascript - 在 Camel 案例转换中让 Camel 开心

我写了驼峰字符串的函数(要求是把单词开头和每个连字符后面的字符踢起来,这是针对人名)。functionsadCamelize(input){returninput.toLowerCase().replace(/([-\s])(.)/g,function(match,separator,starter){returnseparator+starter.toUpperCase();});}现在,我想让我的Camel开心,这样即使是字符串的第一个字符(不是后续空格也不是连字符)都会被启动。Idest,而不是:HONKA-HONKA->honka-Honka我想得到HONKA-HONKA->H