package com.jesse.ticket.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created by LuWenHao on 2017/3/21.
*/
public class test {
public static void main(String[] args) {
// 要验证的字符串
String str = "11111";
// 密码验证规则
String regEx = "^(\\w){8,16}$";
// 编译正则表达式
Pattern pattern = Pattern.compile(regEx);
// 忽略大小写的写法
Matcher matcher = pattern.matcher(str);
// 字符串是否与正则表达式相匹配
boolean rs = matcher.matches();
System.out.println(rs);
}
}
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created by LuWenHao on 2017/3/21.
*/
public class test {
public static void main(String[] args) {
// 要验证的字符串
String str = "11111";
// 密码验证规则
String regEx = "^(\\w){8,16}$";
// 编译正则表达式
Pattern pattern = Pattern.compile(regEx);
// 忽略大小写的写法
Matcher matcher = pattern.matcher(str);
// 字符串是否与正则表达式相匹配
boolean rs = matcher.matches();
System.out.println(rs);
}
}