作用:
    1.字符串的格式校验 String类中提供了一个方法boolean = str.matchs(”regex”);
    2.字符串的拆分及替换 String类中的方法replace split
    3.字符串的查找 Pattern类—->模式 Matcher—->匹配器

    1. //找寻长度为6的任意数字
    2. String str = new String("123456abc787546hghf344538rfgd");
    3. //1.利用Pattern类创建一个对象 相当于正则表达式
    4. Pattern p = Pattern.compile("\\d{6}");
    5. //2.利用Pattern模式对象创建一个匹配器
    6. Matcher m = p.matcher(str);
    7. //3.找寻满足条件的字符串
    8. while(m.find()){
    9. System.out.println(m.group());
    10. //输出 123456 787546 344538
    11. }