learning java 正则表达式

        var regStr = "Java is very good";
        Matcher m  = Pattern.compile("\\w+").matcher(regStr);
        while(m.find()){
            System.out.println(m.group() + " start:" + m.start() + ",end:" + m.end());
        }

output:

Java start:0,end:4
is start:5,end:7
very start:8,end:12
good start:13,end:17

 

posted @ 2019-07-26 11:31  嵌入式实操  阅读(110)  评论(0编辑  收藏  举报