一、先看两个常用的例子
例一:
@Test
public void test() {
Pattern p = Pattern.compile("\\d+");
Matcher m = p.matcher("22bb33");
// 返回false, 因为字符串中含有bb,所以不能全匹配
System.out.println(m.matches());
// 返回true,因为22、33满足条件
System.out.println(m.find());
// 返回true,因为是以22开头,满足条件
System.out.println(m.lookingAt());
Matcher m2 = p.matcher("bb2233");
// false,因为是以bb开头,不满足条件
System.out.println(m2.lookingAt());
Matcher m3 = p.matcher("aaa2223bb");
// 一定要先执行.find()方法,下面才会执行
if (m3.find()) {
// 返回2223
System