`

java正则表达式

阅读更多

    public static void main(String[] args) {
        String aa = "grey_scale_2017-07-13_10014_7";
        Pattern compile = Pattern.compile("_([0-9]+)_");
        Matcher matcher = compile.matcher(aa);
        if (matcher.find()) {
            String group = matcher.group(1);
            System.err.println(group);
        }
    }

 

正则表达式中:

group是针对()来说的

group(0)就是指的整个串

group(1) 指的是第一个括号里的东西

group(2)指的第二个括号里

 

 

0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics