var str = "the-first-name"; console.log(str.replace(/-(\w)/g, function ($, $1) { return $1.toUpperCase(); })); // theFirstName str = "100000000000"; console.log(str.replace(/(?=(000)+$)/g, ".")) // 100.000.000.000