正则表达式在线求助!!! 正则表达式java 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public class Test { public static void main(String[] args) { // 名字 (长度大于2 首个字符不能为数字) String regex_s1 = "^[.[^\\d]]{2,}$"; String[] s1 = getS1(); pattern(regex_s1, s1); // // 性别 (只能是男或则女) String regex_s2 = "^[男|女]$"; String[] s2 = getS2(); pattern(regex_s2, s2); // // //email (只能是@qq.com结尾的)[这里忽略email命名合法性] String regex_s3 = "^([.[^\\s]]{1,})(@qq.com)$"; String[] s3 = getS3(); pattern(regex_s3, s3); // 成绩 (只能是0-100的整数) String regex_s4 = "[\\d][\\d]?[0]?"; String[] s4 = getS4(); pattern(regex_s4, s4); } private static void pattern(String regex, String[] str) { System.out.println("---------------------------------"); for (int i = 0; i < str.length; i++) { String s = str[i]; boolean matches = Pattern.matches(regex, s); System.out.println(regex + ">>" + s + " matches :" + matches); } } private static String[] getS2() { return new String[] { "男", "女", "男女", "男人", "女人" }; } private static String[] getS1() { return new String[] { "隆隆", "小隆隆", "龙", "", "1龙", "1" }; } private static String[] getS3() { return new String[] { "[email protected]", "@qq.com", " @qq.com", "", "[email protected]", "[email protected]" }; } private static String[] getS4() { return new String[] { "50", "-1", "101", "105", "", "1.1", "a", "*", "8", "5" }; }}如有错误请纠正 http://blog.sina.com.cn/s/blog_7d0ef6bf0101ixr5.html去抄吧 求圣思园 视频,跪求!!!好人 Java新手 高手看看 java中让弹出的多个Dialog实现层叠,水平平铺,垂直平铺 如何将这行c#接口转化成java接口,再线等,谢谢 新手问oracle问题!能帮忙的帮帮我!!! strts-config.xml配置 急救~~~~~~~~~~~~~~~~求光标顺序控制 有人用过GeneralPath吗? 各位老大:使用JTextField组件添加DocumentListener监听内容改变时,如何动态的获得它当前的录入值? 为什么运行结果是1234.请详细解答 ClassLoader类加载器获取方式 数据匹配插入问题
// 名字 (长度大于2 首个字符不能为数字)
String regex_s1 = "^[.[^\\d]]{2,}$";
String[] s1 = getS1();
pattern(regex_s1, s1); // // 性别 (只能是男或则女)
String regex_s2 = "^[男|女]$";
String[] s2 = getS2();
pattern(regex_s2, s2);
//
// //email (只能是@qq.com结尾的)[这里忽略email命名合法性]
String regex_s3 = "^([.[^\\s]]{1,})(@qq.com)$";
String[] s3 = getS3();
pattern(regex_s3, s3); // 成绩 (只能是0-100的整数)
String regex_s4 = "[\\d][\\d]?[0]?";
String[] s4 = getS4();
pattern(regex_s4, s4);
} private static void pattern(String regex, String[] str) {
System.out.println("---------------------------------");
for (int i = 0; i < str.length; i++) {
String s = str[i];
boolean matches = Pattern.matches(regex, s);
System.out.println(regex + ">>" + s + " matches :" + matches);
}
} private static String[] getS2() {
return new String[] { "男", "女", "男女", "男人", "女人" };
} private static String[] getS1() {
return new String[] { "隆隆", "小隆隆", "龙", "", "1龙", "1" };
} private static String[] getS3() {
return new String[] { "[email protected]", "@qq.com", " @qq.com", "", "[email protected]", "[email protected]" };
} private static String[] getS4() {
return new String[] { "50", "-1", "101", "105", "", "1.1", "a", "*", "8", "5" };
}
}
如有错误请纠正