I’d like to replace all the tag-looking parts in a String if those are not valid HTML tags.
A tag-looking part is something enclosed in <> brackets. Eg. <myemail@email.com> or <hello> but <br>, <div>, and so on has to be kept.
Do you have any idea how to achieve this?
Any help is appreciated!
cheers,
balázs
You can use JSoup to clean HTML.
You can either use one of the defined Whitelists or you can create your own custom one in which you specify which HTML elements you wish to allow through the cleaner. Everything else is removed.
Your specific example would be:
Output: