You need to sign in to do that
Don't have an account?
marOne
How to get a rich text area content without HTML markups
Hello everybody, This is my first Salesforce post.
In my controller, I use a query to get the field related to a rich text area.
My need is to get, for example, 200 first character of a rich text area without HTML markup.
I don't know if a method already exists to perform this because when I try to change the field type from rich text area to text area, Salesforce propose if I want to keep or not the HTML markup of rich text area contents.
Thank you
M.
You can use a regex to replace any html tags.
Why do you want to strip out the html content?
I guess
is a better regex. At least that's what served me well for the last 15 years.
Is it possible to replace all HTML tags except hyperlinks (<a> tags) and image tags (<img .. >)?
Hi,
Currently I am facing same issue. I want to remove other HTML tags except hyperlinks and Image tags. Have you solved the issue.
Not yet.
have you ever found a solution for this? I'm just struggling with exactly this problem...
I want to copy content of a rich text field into a field which is only long text. As soon as there is any formatting in the rich text field the long text field contains any Markup/HTML tags and gets worse. Since the target field is from a managed package (Agile Accelerator) I'm not free to change the field type there.
I'm completely open how to fill the new field: ProcessBuilder, Workflow rule/Field update or apex trigger - but anyway, the problem remains.
I tried to remove all HTML tags from the text in the trigger, but I also loose newlines or tabs and it still looks ugly.
Thanks and best regards - Elke
String s= fieldName.replaceAll('<[^>]+>',' ');
https://stackoverflow.com/questions/11229831/regular-expression-to-remove-html-tags-from-a-string
According to the article, an example for eliminating a specific kind of tag would be the following:
String target = someString.replaceAll("(?i)<td[^>]*>", "");
String temp = temp.replaceAll('</?h.*?>|</?s.*?>|</?f.*?>','');
String str2 = str1.stripHtmlTags();