You need to sign in to do that
Don't have an account?

Capitalization list back to string
Hello, I have a daily-scheduled-import of several new records, and names come in with inconsistent capitalization. I want my before insert trigger to make all the names appear normal (first letter of each name capital, the rest lower case.) I found code so far which does this but it leaves it as a list. How can this return a normal string of the name, with first then last name, in the normal format I want?
String s;
s = 'joHN JONSOn';
String [] lines = s.split('\n');
integer j = 0;
for (String line:lines) {
String [] words = line.split(' ');
integer i = 0;
for (String word:words) {
words[i] = word.trim().tolowercase().capitalize();
i++;
}
lines[j] = String.join(words,' ');
j++;
s = string.valueof(lines);
system.debug(s);
}
String s;
s = 'joHN JONSOn';
String [] lines = s.split('\n');
integer j = 0;
for (String line:lines) {
String [] words = line.split(' ');
integer i = 0;
for (String word:words) {
words[i] = word.trim().tolowercase().capitalize();
i++;
}
lines[j] = String.join(words,' ');
j++;
s = string.valueof(lines);
system.debug(s);
}
Try following
Let me know if this helps.
All Answers
Try following
Let me know if this helps.