how to print html tags using regx in jsp
I wanna print string, which include "< >" in it, to the web page using
JSP. I need to replace any ">" and "<" to "<" and ">". My string
should be "java/io/Object" or "<init>", etc. Can anyone give me a pattern?
I know two method to replace strings. But I dont know how to use it.
1
String ss = s.replaceAll("(?i)<a.*?>(.*?)</a>", "$1");
System.out.println(ss);
2
Pattern replace = Pattern.compile("(?i)<a.*?>(.*?)</a>");
Matcher matcher2 = replace.matcher(s);
System.out.println(matcher2.replaceAll(""));
which one will replace string fast? thx for ur time. EDIT: I am not trying
to escaping html tags. The strings like "<init>" is not print in the web
page, but it exists in the html source file, since the browser make it as
a tag.
No comments:
Post a Comment