String regex1 = "^\\d+(\\,)*(\\d)*$";
System.out.println("123,345,2423,".matches(regex1));
String regex2 = "([0-9]+[,]?)+";
System.out.println("1111,2222,3333,,4444,".matches(regex2));
String regex3 = "(\\d+)(,\\d+)*";
System.out.println("1111,2222,3333,4444".matches(regex3));
正则验证
最新推荐文章于 2024-05-12 11:52:18 发布