How to get last/first n char from a String using Apex in Salesforce
- Amol Wagh
- Mar 20, 2024
- 1 min read
Updated: Jul 8, 2024
.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
コメント