常用正则
驼峰转连字符(中划线)
s = s.replace(/([A-Z])/g,"-$1").toLowerCase();
连字符转驼峰
function toHump(name) {
return name.replace(/\-(\w)/g, function(all, letter){
console.log(all) //"_T"
console.log(letter) //"T"
return letter.toUpperCase();
});
Comments