java多次替换(replace不行)

import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class test {

    public static void main(String args[])
    {
        String a="[<<>><<>>]";
        
        String regEx_script="<";    
        String regEx_style= ">";  

         //过滤script标签     
        Pattern p_script=Pattern.compile(regEx_script,Pattern.CASE_INSENSITIVE);    
        Matcher m_script = p_script.matcher(a);
        a = m_script.replaceAll("&lt;");
         
        Pattern p_style = Pattern.compile(regEx_style,Pattern.CASE_INSENSITIVE);     
        Matcher m_style = p_style.matcher(a);      
        a= m_style.replaceAll("&gt;");
        System.out.println(a);
    }
}

 

posted @ 2013-11-20 15:26  yufenghou  阅读(2325)  评论(0编辑  收藏  举报