I have a regex that transform a uppercase/lowercase string in a capitalized string. The problem in that in my country it's normal to have special characteres in the name, and it bugs my response
const updatedInput = input
.replace(/\w+/g, (txt) => {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
})
.trim();
If I use this method with "JOAO CARLOS NOBREGA ", the return is "Joao Carlos Nobrega". But if I use this method with "JOÃO CARLOS NOBREGA ", the return is "JoãO Carlos Nobrega". How can I solve this?