12
I have this Function:
var titleCase = function(s) {
return s.replace(/(\w)(\w*)/g, function(g0, g1, g2) {
return g1.toUpperCase() + g2.toLowerCase();
});
}
If I call her by passing something she works right:
var teste = titleCase("apenas um teste"), //"Apenas Um Teste"
teste2 = titleCase("oUTRO.tesTE"); //"Outro.Teste"
But when I have an upperChar in the middle of the text, it should keep it, but instead is ignoring it:
var teste3 = titleCase('testeControl'); //"Testecontrol"
Any suggestions for me to have on teste3
the result "TesteControl"
?
It doesn’t matter if you break the teste2
.
+1 very cool that question
– Wallace Maxters