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");
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
本文链接:https://www.haomeiwen.com/subject/spggpttx.html
网友评论