需求是这样的let str = 'phone_number' // 变成 Phone Number
实现
const upperCase = ([first, ...rest]: string) => `${first.toUpperCase()}${rest.join('').replace(/(_.)/, ([_, $str]: string) => ' ' + $str.toUpperCase())}`;
需求是这样的let str = 'phone_number' // 变成 Phone Number
实现
const upperCase = ([first, ...rest]: string) => `${first.toUpperCase()}${rest.join('').replace(/(_.)/, ([_, $str]: string) => ' ' + $str.toUpperCase())}`;