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("<"); Pattern p_style = Pattern.compile(regEx_style,Pattern.CASE_INSENSITIVE); Matcher m_style = p_style.matcher(a); a= m_style.replaceAll(">"); System.out.println(a); } }