You would be better off using a function as the second parameter in replace()
, and you could also use a regex literal instead of the RegExp
constructor:
var replaced = '-moz-border-radius'.replace(/-([a-z])/gi, function(s, group1) {
return group1.toUpperCase();
});