String s="fhdjfhk<scripT djfjl <SCRipt";
String reg = "/(<)((s|S){1}(c|C){1}(r|R){1}(i|I){1}(p|P){1}(t|T){1})/";
org.apache.oro.text.perl.Perl5Util perl = new Perl5Util();
while (perl.match(reg, s)) {
s = perl.substitute("s/(<)((s|S){1}(c|C){1}(r|R){1}(i|I){1}(p|P){1}(t|T){1})/$1 $2/", s);//$1$2之间有个空格.
}
System.out.println(s);
String reg = "/(<)((s|S){1}(c|C){1}(r|R){1}(i|I){1}(p|P){1}(t|T){1})/";
org.apache.oro.text.perl.Perl5Util perl = new Perl5Util();
while (perl.match(reg, s)) {
s = perl.substitute("s/(<)((s|S){1}(c|C){1}(r|R){1}(i|I){1}(p|P){1}(t|T){1})/$1 $2/", s);//$1$2之间有个空格.
}
System.out.println(s);
Pattern p=Pattern.compile(regEx,Pattern.CASE_INSENSITIVE); //匹配时忽略字母大小写
String tag="....."; //这里写你要处理的字符串
Matcher m=p.matcher(tag); String s=m.replaceAll("< script"); //这里是处理后的字符串,其中"< script"可以任意写,也就是你可以写成你所想替换成的字符
在php中一般用这样的方法:
$tt = $value;
$tt = str_replace('amp;','',$tt);
$tt = str_replace(''',"'",$tt);
$tt = str_replace('"','"',$tt);
$tt = str_replace('<', '<',$tt);
$tt = str_replace('>', '>',$tt);
return $tt;
读取时采用下面的函数
htmlspecialchars($value,ENT_QUOTES);
不知道jsp里面有没有,自己找找吧