function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NHKNHK 

How to get a rich text area Content

Hi All,

 

I need to get the content of Rich Text Area Field without HTML markup when i query the field. Is there any method to get the text data excluding the markup?

 

Thank you in Advance,

 

Best Regards,

NHK

amilawamilaw

 try this

 

String richTextVal = '<p><b>text</b></p>';
String RegEx ='(</{0,1}[^>]+>)';
richTextVal = richTextVal.replaceAll(RegEx, '');
system.debug(richTextVal);

NHKNHK

Hi Amilaw,

 

Thank you for your reply. 

 

If we use RegEx function, we canot retain the values with quot. 

For Ex: richTextVal  = <b> "This is a text value" </b>

Then the result will be like &quot;This is a text value&quot;

 

Best Regards,

NHK

NHKNHK

Hi All,

 

Let me explain my scenario.

 

We have a custom object with few Rich Text Fields. We are using a middleware to query the records of custom object and sending it to a tool which Prepares a PPT out of it. Since the Rich Text field value is stored as HTML markup, the PPT is not displying properly. We need to avoid the markup and display only the Text data. 

 

If anyone have any ideas, please share it.

 

Thank you,

 

Best Regards,

NHK

amilawamilaw

are you sure. for me result was as expected

 

String richTextVal = '<p class="tst"><b>"text"</b></p>';
String RegEx ='(</{0,1}[^>]+>)';
richTextVal = richTextVal.replaceAll(RegEx, '');
system.debug(richTextVal);

 

resulted --> "text"

 

did you used any string html methods