将字符串转换为 spinal case

spinalCase = (str) => {
return str.replace(/([^[A-Za-z-])|(\w)([A-Z])/g, (...match)=> {
return match[1] !== undefined ? '-' : match[2]+'-'+match[3];
}).toLowerCase();
};

spinalCase("thisIs_SpinalTap T");

你可能感兴趣的:(将字符串转换为 spinal case)