regex to escape non-html tags' angle brackets

Posted by suad on Stack Overflow See other posts from Stack Overflow or by suad
Published on 2010-03-22T15:36:56Z Indexed on 2010/03/22 15:41 UTC
Read the original article Hit count: 305

Filed under:
|

Hi I have an html based text (with html tags), I want to find words that occur within angle brackets and replace the brackets with < and > or even when angle brackets are used as math symobls

e.g:

String text= "Hello, <b> Whatever <br/> <table> <tr> <td width="300px"> 1<2 This is a <test> </td> </tr> </table>";

I want this to be :

Hello, <b> Whatever <br/> <table> <tr> <td width="300px"> 1&lt;2 This is a &lt;test&gt; </td> </tr> </table>

THANKS in advance

© Stack Overflow or respective owner

Related posts about java

Related posts about regex