-2

I need to replace(escape) all html tags except of <br> tag with &lt;tag&gt;. I have tried following:

String text = "<br><tag>";
text.replaceAll("<[^br]", "&lt;");

which replace the first character of tag:

$34 ==> "<br>&lt;ag>"

Any idea how to aproach this without having to parse and save the first character first and then add it to regex?

Hynek Hrabík
  • 73
  • 1
  • 10

0 Answers0