You need to sign in to do that
Don't have an account?
BPOOR
rtrim not working
I need to remove the trailing spaces from a String. However, when I try that in Execute Anonymous window with the below test apex code, I am getting the below error message.
I need to retain the leading spaces, if there are any. So, I can't use the trim() method.
I also tried without the second parameter, and it did not work either.
Can someone help?
String testString = 'ABCD124 '; System.debug('Trimmed string = ' + rtrim(testString,' ')); Method does not exist or incorrect signature: void rtrim(string, string)
I need to retain the leading spaces, if there are any. So, I can't use the trim() method.
I also tried without the second parameter, and it did not work either.
Can someone help?
String testString = 'ABCD124 ';
System.debug('Trimmed string = ' +testString.trim());
Thanks
I used the below code and it worked perfectly.
String regExp = '\\s+$';
System.debug('Trimmed String = ' + testString.replaceAll(regExp, '');