December 24, 2014

How to remove leading or trailing white space characters using Apex in Salesforce?

To remove leading or trailing white space characters using Apex in Salesforce, trim() is used.

Sample Code:

String str1 = ' test   ';
String str2 = str1.trim(); //test will be output without any white spaces

Cheers!!!

No comments:

Post a Comment