var str2 = 'border-bottom-color'; function test(str2){ var re = /(-)(\w)/g; return str2.replace(re, function($0, $1,$2){ // console.log($0 + ':' + $2) return $2.toUpperCase(); }); } alert(test(str2));
$0代表整个。$1代表第一组,$2 代表第二个