TA的每日心情 | 开心 2021-3-12 23:18 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
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,"
","<br>");
re=replace(re," "," ");
re=replace(re,""","'");
return re;
}
} |
|