将字符串转换为 spinal case

2016-11-27  本文已影响0人  户人

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");

上一篇下一篇

猜你喜欢

热点阅读