Matcher匹配器查找字符串指定内容

public static void main(String[] args) {
        String s = "我的手机号码是18988888888,曾经用过18987654321,还用过18812345678";
        String regex = "1[3578]\\d{9}";
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(s);
        while (m.find()) {
            System.out.println(m.group());
        }
    }

 

posted @ 2019-01-07 18:58  苦瓜爆炒牛肉  阅读(592)  评论(0编辑  收藏  举报