How to get Sub String of String using two Strings in Salesforce using Apex?

How to get Sub String of String using two Strings in Salesforce using Apex?

substringBetween() is used to get Sub String of String using two Strings in Salesforce using Apex.

Sample Code:

String s1 = ‘abTestingcd’;
String s2 = s1.substringBetween(‘ab’,’cd’);
system.debug(‘s2 is ‘ + s2);//Testing

Output:

Cheers!!!

Leave a Reply