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
Post a Comment