public class Utilities {
public static String titleCaseEveryWord(String str) {
List<String> words = str.toLowerCase().split(' ');
String finalStr = '';
for (String word : words) {
finalStr += word.substring(0, 1).toUpperCase() + word.substring(1, word.length()) + ' ';
}
return finalStr;
}
}
Apex: Title Case Every Word
Apex code snippet to title case every word in a string.