Is there a simple way to convert a string to title case? E.g. john smith
becomes John Smith
. I\'m not looking for something complicated like John R
Taking the "lewax00" solution I created this simple solution that force to "w" starting with space or "w" that initiate de word, but is not able to remove the extra intermediate spaces.
"SOFÍA vergara".toLowerCase().replace(/\b(\s\w|^\w)/g, function (txt) { return txt.toUpperCase(); });
The result is "Sofía Vergara".