开头是两个数字,然后中间有一个连接符,然后连接符-后面还有5位数字的正则
package org.litsoft.air.servlet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TestString {
public static boolean isRight(String str){
boolean flag=false;
String regex="^([0-9]{2}-[0-9]{5})+$";
Pattern pattern=Pattern.compile(regex);
Matcher match=pattern.matcher(str);
if(match.matches()){
flag=match.matches();
System.out.println(match.group());
}
return flag;
}
public static void main(String[] args) {
boolean flag=false;
String str="24-99999";
flag=new TestString().isRight(str);
System.out.println("flag="+flag);
}
}