My requirement is to extract specific string from a email subject like.
My email subject always like:
Fleet Invoice inv - account name
I need to extract account name from above subject line.
Always they use same specific template.
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
The Apex String class provides a lot of useful methods.
In your case, I'd use the
substringAfter(separator) method to get the end of your String after the '-' character. Like this:
String accountName = yourSubject.substringAfter(' - ');