package com.springmvchibernate.ContinuingEducation.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 过滤特殊字符返回
*
* @author
* */
public class FilterCode {
public FilterCode(){};
public String str;
public String replace;
public String getStr() {
if(this.DelHtmlTag().length()>10){
replace="...";
return this.DelHtmlTag().substring(0, 10).toString()+replace;
}
return this.DelHtmlTag();
}
public void setStr(String str) {
this.str = str;
}
public static String checkCode(String str) {
String regEx = "[\"\"`~!#$%*()+=|{}':;',\\[\\]<>/?~!#¥%()——+|{}【】、?^\\s]";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(str);
return m.replaceAll("").toString();
}
public String DelHtmlTag(){
String regEx="<.+?>"; //表示标签
Pattern p=Pattern.compile(regEx);
Matcher m=p.matcher(this.str);
String s=m.replaceAll("");
return s;
}
public String DelHtmlTag(String str){
String regEx="<.+?>"; //表示标签
Pattern p=Pattern.compile(regEx);
Matcher m=p.matcher(str);
String s=m.replaceAll("");
return s;
}
}