function ReplaceFirstUper(str) { str = str.toLowerCase(); return str.replace(/\b(\w)|\s(\w)/g, function(m){ return m.toUpperCase(); }); } console.log(ReplaceFirstUper(‘i have a pen, i have an apple!‘));
时间: 2024-12-18 09:41:39
function ReplaceFirstUper(str) { str = str.toLowerCase(); return str.replace(/\b(\w)|\s(\w)/g, function(m){ return m.toUpperCase(); }); } console.log(ReplaceFirstUper(‘i have a pen, i have an apple!‘));