How to Replace String Values in Visualforce Page

SUBSTITUTE – new text for old text in a text string.


{!SUBSTITUTE(Lead.Company, " ", "")} //Remove the Space in Lead Company
{!SUBSTITUTE(Account.Name, "", "")} //Remove dot value in Account Nmae
<apex:outputText value="{!
        SUBSTITUTE(Account.Description, '[', '<sup>'),
        ']', '</sup>'
}" escape="false"/>

Replace String function using Apex Class in Salesforce

String str = ‘TheBlogReaders’;
Str = str.replace(‘Blog’,’Salesforce’);
System.debug(‘Output::’+ str);
23:18:23:002 USER_DEBUG [3]|DEBUG|Output::TheSalesforceReaders

Written by 

3x Salesforce MVP | Platform Champion | 18x Salesforce Certified | MuleSoft Certified | 8x Trailhead Ranger | TechForce Services | Sydney | Australia

Leave a Reply

Your email address will not be published.