Salesforce Fact #600 | Remove first and last occurrence of char from string

There is a method named substringBeforeLast() in String class which is helpful in getting the substring before last occurrence of a particular character.

Suppose, we wrapped a particular string with a particular char at the start and also at the end. Now, to get the exact string we need to remove the very first and very last occurrence of that char. substringBeforeLast() method along with the substring() method could be handy here.

Attached is the screenshot.



Comments

Popular posts from this blog

Salesforce Fact #192 | Call batch apex from flow

Salesforce Fact #457 | Get current user role name in flow