4

Now I have this regex: tSzoveg = tSzoveg.replace(/\b[A-Z]{2,}\b/,'');

It is almost that I want. I want to convert this: THIS IS MINE, NOT YOURS. to this: This is mine, not yours.

How can I convert it to a normal sentence?

user2301881
  • 320
  • 5
  • 16
  • Not quite a duplicate: That question asks to leave the remaining characters alone; this question asks to downcase the remaining characters. – Wayne Conrad Mar 20 '14 at 13:45

2 Answers2

4
function capitalize(string)
{
    return string.toUpperCase().charAt(0) + string.toLowerCase().slice(1);
}
destan
  • 4,301
  • 3
  • 35
  • 62
1

I would use toLowerCase() and then modify the first letter:

var str = "THIS IS MINE, NOT YOURS."
str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
shilovk
  • 11,718
  • 17
  • 75
  • 74
slinky2000
  • 2,663
  • 1
  • 15
  • 12