齐天大圣数据候 2020-04-26
var hyphenateRE = /\B([A-Z])/g;
var hyphenate = function (str) {
return str.replace(hyphenateRE, ‘-$1‘).toLowerCase()
}
console.log(hyphenate("aaaaDssssFcccc"));? ? //??aaaa-dssss-fcccc
// "-$1":捕获到什么字符$1就引用什么字符,字符加一个“-”