📄 regexvalidator.java
字号:
package com.exp.web.util.validator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.exp.fcl.xml.EXPXMLNode;
import com.exp.web.util.FormBean;
public class RegexValidator extends BaseValidator {
protected String regex = "";
protected boolean bCaseInsensitive = false;
protected void initConfig(EXPXMLNode validator) {
this.regex = validator.getAttributeValue("regex");
String temp = validator.getAttributeValue("case-insensitive");
if (temp.equals("true")) {
this.bCaseInsensitive = true;
}
}
public boolean checkValid(FormBean formBean) {
try {
String value = formBean.getString(this.getTarget());
if (this.bCaseInsensitive) {
Pattern p = Pattern.compile(this.regex,
Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(value);
return m.matches();
} else {
Pattern p = Pattern.compile(this.regex);
Matcher m = p.matcher(value);
return m.matches();
}
} catch (Exception e) {
return false;
}
}
protected String genCheckCondition() {
return this.matchRegExp(this.regex, this.bCaseInsensitive);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -