package regular;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegularExpress {
private static Pattern illegal_database_field =Pattern.compile("[(\\W+) && [^-+#]]");
public static boolean checkIllegalField(String fieldName) throws Exception{
Matcher matcher = illegal_database_field.matcher(fieldName);
while(matcher.find()){
System.out.println(matcher.group(0));
return true;
}
return false;
}
public static void main(String[] args) throws Exception{
String fieldName = "ö12345fsdfasfda";
RegularExpress regularExpress = new RegularExpress();
System.out.println(regularExpress.checkIllegalField(fieldName));
}
}
Regular Expression
最新推荐文章于 2025-03-07 22:35:24 发布
本文介绍了一个使用正则表达式检测数据库字段中非法字符的Java程序,包括正则表达式的定义、方法实现及实例应用。
1万+

被折叠的 条评论
为什么被折叠?



