top of page
Writer's pictureAmol Wagh

How to get last/first n char from a String using Apex in Salesforce

Updated: Jul 8

.right() is used to get last n char from a String using Apex.

.left() is used to get first n char from a String using Apex.


Example:


String str = 'SalesforceCloudwaale';

String result = str.right(10); //returns Cloudwaale



String str = 'SalesforceCloudwaale';

String result = str.left(10); //returns Salesforce

0 comments
SIGN UP AND STAY UPDATED!

Thanks for submitting!

© 2019 by cloudwaale

bottom of page