SOURCE

// let reg = /(_)([a-zA-Z])/g;
// const test = "a_bc";
// console.log(test.replace(reg, function(fullMatch){
//     console.log(fullMatch)
//     return fullMatch[1].toUpperCase();
// }));

function changeStr(str){
    const reg1 = /_([a-z])/
    if(reg1.test(str)){
       str = str.replace(reg1,(...args)=>{
            return args[1].toUpperCase()
        })
       return changeStr(str) 
    }
    return str
}

// test region
const test = "a_bc_kkk";
console.log(changeStr(test))

console 命令行工具 X clear

                    
>
console