function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
pierrepierre 

Apex Proper(String) function - code

the function works, can you suggest improvements?

public static String proper(String astring) {
if (astring != null) {
String result = '';
String[] regs = astring.trim().split('[ \t\n\r]',0); // any whitespace character, does not allow all Java reg exps unlike the doc says
//System.debug(' regs.length()='+regs.size());
for(String reg : regs) {
//System.debug(' reg:'+reg+' length:'+reg.length());
if (reg.length() >0) {
result += reg.substring(0,1).toUpperCase();
if (reg.length()>1) result += reg.substring(1).toLowerCase();
result+=' ';
}
}
return result.trim();
}
return null;
}

..feels like in computer science class all over again

Message Edited by pierre on 12-03-2008 04:07 PM