ziwei3749 / blog

已停止更新..转移至 https://segmentfault.com/u/ziwei3749
9 stars 1 forks source link

正则练习 #6

Open ziwei3749 opened 6 years ago

ziwei3749 commented 6 years ago

正则练习

题目1: 把类似于 is_good 这样的变量名替换成 isGood

原题: http://scriptoj.mangojuice.top/problems/29

       const toCamelCaseVar = (str) => {
            return str.replace(/([^_])_+([^_])/g,(match,$1,$2,index,str) => {
                console.log(match)
                console.log($1)
                console.log($2)
                return $1+$2.toUpperCase()
            })
        }

注意点: