驼峰命名转下划线命名

function toUnderLine(str) {
    let nstr = str.replace(/[A-Z]/g, function ($0) {
        return "_" + $0.toLocaleLowerCase();
    })
    if (nstr.slice(0, 1) == "_") {
        nstr = nstr.slice(1)
    }
    return nstr
}
posted @ 2022-10-26 16:57  田心夂  阅读(15)  评论(0)    收藏  举报