[SalesForce] substitute multiple substrings in visualforce page

I am trying to substitute multiple substrings in a value on a visualforce page. I tried using nested SUBSTITUTE() functions, but I get an error message "The element type "p" must be terminated by the matching end-tag "

"."

<p class="product-name">
    {!SUBSTITUTE(SUBSTITUTE(p.Product2.Short_Product_Description__c, "{", "<sup>"),"}", "</sup>")}
</p>

Note: I am able to do a single substring substitution with a single SUBSTITUTE() call like so:

<p class="product-name">
    {!SUBSTITUTE(p.Product2.Short_Product_Description__c, "{", "<sup>")}
</p>

However this is undesirable as I also need to substitute the "}" character with a "</sup>"

Best Answer

This is the solution I found that works:

<apex:outputText value="{!
    SUBSTITUTE(
        SUBSTITUTE(p.Product2.Short_Product_Description__c, '[', '<sup>'),
        ']', '</sup>'
    )
}" escape="false"/>

The curly braces are what was triggering it and an with escape attribute set to false is required to render the html properly

Related Topic