I basically have a form that takes user input and I match it in the database. I want the first character uppercase and characters with spaces and all others lowercase. Right now I have this
location= location.split(' ').map(_.capitalize).mkString(" ")
The code above does this: if a user types 'new york' it gets converted to 'New York', however if a user types NeW YoRk I still want it converted to the form 'New York'.
Just convert it all to lowercase first:
_.toLowerCase.capitalize
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments