HTML标记过滤 站点:爱心种子小博士 关键字:HTML标记过滤
|
HTML标记过滤 package user;
public class HtmlEncode{
String re;
public String replace(String con,String tag,String rep){
int j=0;
int i=0;
int k=0;
String RETU="";
String temp=con;
int tagc=tag.length();
while(i<con.length()){
if(con.substring(i).startsWith(tag)){
temp=con.substring(j,i)+rep;
RETU+=temp;
i+=tagc;
j=i;
}else{
i+=1;
}
}
RETU+=con.substring(j);
return RETU;
}
public String htmlEncode(String s){
re=replace(s,"<","<");
re=replace(re,">",">");
re=replace(re,"\n","<br>");
re=replace(re," "," ");
re=replace(re,"","'");
return re;
}
} |
|
|
|