user998263
user998263

Reputation: 1

Escape HTML as well as \r \t and \n from a string

I am trying to index solar search from a built string in a code which has HTML tags. Any one knows how I can remove all the characters from the String.

Currently, I am using

answers << answer.feedback.replaceAll('\\<.*?>','')

I want to escape all the HTML characters and all the \n \t and \r. How to do this?

Upvotes: 0

Views: 1266

Answers (1)

Jan Wikholm
Jan Wikholm

Reputation: 1575

Do you want to escape the html tags so that <span> becomes &lt;span&gt; or do you want to REMOVE the tags themselves. Your original question is ambiguous.

For the first scenario:

answer.feedback.encodeAsHTML() 

(see http://grails.org/doc/latest/ref/Plug-ins/codecs.html for further info)

Upvotes: 1

Related Questions