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);

解决方案 »

  1.   

    import java.util.regex.*;String regEx="<script>";
    Pattern p=Pattern.compile(regEx,Pattern.CASE_INSENSITIVE);  //匹配时忽略字母大小写
    String tag=".....";  //这里写你要处理的字符串
    Matcher m=p.matcher(tag); String s=m.replaceAll("< script");  //这里是处理后的字符串,其中"< script"可以任意写,也就是你可以写成你所想替换成的字符
      

  2.   

    我想应该是把“<"与">","'" 还有双引号进行转换之后再进行就没有什么问题了
      

  3.   

    就是对那些字符进行编码
    在php中一般用这样的方法:
    $tt = $value;
    $tt = str_replace('amp;','',$tt);
    $tt = str_replace('&#039;',"'",$tt);
    $tt = str_replace('&quot;','"',$tt);
    $tt = str_replace('&lt;', '<',$tt);
    $tt = str_replace('&gt;', '>',$tt);
    return $tt;
    读取时采用下面的函数
    htmlspecialchars($value,ENT_QUOTES);
    不知道jsp里面有没有,自己找找吧