JS正则表达式:全文单词首字母大写

JS正则表达式:全文单词首字母大写正则表达式

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!'));