美文网首页
将字符串转换为 spinal case

将字符串转换为 spinal case

作者: 户人 | 来源:发表于2016-11-27 00:45 被阅读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");

    相关文章

      网友评论

          本文标题:将字符串转换为 spinal case

          本文链接:https://www.haomeiwen.com/subject/spggpttx.html