//正则表达式常量
public class RegularConstant {
public static final String SPECIAL_CHAR = "[^%&',;=?$\`~!@#\*-+_\x22]+";
}
备注:这里为键盘上方常见特殊字符,如需更多字符,可按照规则在“\x22”前加入所需其它字符。
//基本服务类
public class baseService {
public boolean isSpecialChar(String v) {
return v.matches(RegularConstant.SPECIAL_CHAR);
}
}
//调用类
if (!isSpecialChar(mchName)) {
throw new BizException("第【" + rowIndex + "】行第【5】列'企业名称':【" + mchName + "】不能含有特殊字符");
}


