ITeye博客

java正则表达式

shuizhaosi888 · 2017-07-13 21:19 · java基础 · 编程语言 · Markdown


    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)

暂无评论。

评论功能维护中,当前仅展示历史评论。