How to Replace String Values in Visualforce Page

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

Example:

{!SUBSTITUTE(Lead.Company, " ", "")} //Remove the Space in Lead Company
{!SUBSTITUTE(Account.Name, "", "")} //Remove dot value in Account Nmae
<apex:outputText value="{!
    SUBSTITUTE(
        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);
Output:
23:18:23:002 USER_DEBUG [3]|DEBUG|Output::TheSalesforceReaders

Written by 

I am Sakthivel Madesh, a certified Salesforce Advanced Developer & Administrator working on Salesforce Technology since 2011. I am currently working in Techforce Services as Sr. Salesforce Developer. I have worked on multiple technologies Like PHP, Java, Salesforce, I am very passionate about Salesforce and to earn 14x Salesforce Certification. I love Trailhead for learning Salesforce Skill and Become a Trailhead 5x Ranger too. I Love to Learn & Share my Salesforce knowledge to Salesforce Learners/Beginner using My Blog and Salesforce Community.

Leave a Reply