RT 6到20位数字和字母组合 正则表达式,也就是既要有数字也要有字母 不区分大小写

问题描述:

RT 6到20位数字和字母组合 正则表达式,也就是既要有数字也要有字母 不区分大小写
1个回答 分类:综合 2014-09-25

问题解答:

我来补答
不多说直接上代码
java版
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ZhengZe {
    public static void main(String z[]) {
        Pattern pat = Pattern.compile("[\\da-zA-Z]{6,20}");
        Pattern patno = Pattern.compile(".*\\d.*");
        Pattern paten = Pattern.compile(".*[a-zA-Z].*");
        String str = "111111111111111111aa";
        Matcher mat = pat.matcher(str);
        Matcher matno = patno.matcher(str);
        Matcher maten = paten.matcher(str);
        if(matno.matches()&& maten.matches() && mat.matches()){
            System.out.println(str);
        }
    }
}
 
 
展开全文阅读
剩余:2000
上一页:这一步看不懂
下一页:这题详细解释