Saturday, 7 September 2013

replace all instances of < and > but not text between them

replace all instances of < and > but not text between them

How to extract the text between tags?
to get text inbetween tags, the below code works fine,
System.out.println("<text>google<text/>".replaceAll("<[^>]*>", "")); //
gives google
Am trying the same for &lt; and &gt;. Am I missing anything for the below
code?
System.out.println("&lt;aksdk&gt;google&lt;aksdk&gt;".replaceAll("&lt;[^.]*&gt;",
""));
PS: Am not using this for html parsing.

No comments:

Post a Comment