Remove all HTML Tags from summary

Hi,
Can anyone tell me how to remove all HTML Tags from the summary without having to individually removing each tag?
I’d like to use regular expression - something like:
${s.result.metaData[“c”]!?replace(“<[a-zA-Z/][^>]*>”, “”, "g ")

Collection type - database
The text coming from the DB is rich text and I don’t want to use <#noescape> because truncating will result in
<stron… hence will break the layout due to the closing tag missing.
HTML tags are showing at the fornt-end.
Thank you
N

The ideal solution would be to remove them at the source (eg. in a special view that contains the cleaned content) but that may not be possible.

We have a request for an indexer option to do this but it’s still on the backlog unfortunately.

In the mean time you can remove the tags as you’ve suggested in the template layer to remove each tag.

Alternatively you could remove them from the field that you’re interested in by using a post process hook script that does a replace on the value.

see: Hook scripts - Funnelback Documentation - Version 15.14.0

Unfortunately not possible from the source. I had a look at the docs but is there a chance you could show me an example?
something like:

transaction?.response?.resultPacket?.results.each() {
  // In Groovy, "it" represents the item being iterated
  if ( it.metaData["c"] != __NULL__  ) {     
   // how would you do a find and replace??  i.e <h2> </h2> <ul> <li> etc       
  }
 }

Thanks
Nick

I think I have just figured it out using:

  it.metaData.c = (it.metaData.c =~ /<[^>]*>/).replaceAll("") 

Can you confirm Peter?
regards
Nick

Hi Nick,

I think what you have there is pretty much what you want. You might also need to account for an unclosed tag at the end of the description if it’s been truncated at all when indexing or displaying - either increase the size of the indexed field to ensure it doesn’t get truncated (check the -mdsfml indexer option which sets the max size for the metadata field and possibly the -MBL query processor option which controls the metadata display buffer).

cheers,
Peter

1 Like

Thanks Peter,
The text coming has a lot of html formatting and is too big to account for all of it. I may need to get our people to incorporate a “summary field” that we can map to with no html and appropriate size for display.

Thank you once again for your assistance
N