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 it is ignoring it:
var teste3 = titleCase('testeControl'); //"Testecontrol"
Any suggestions for me to have teste3
result "TesteControl"
?
It does not matter if you break teste2
.