---
title: "java正则表达式"
author: "shuizhaosi888"
date: "2017-07-13T21:19:50Z"
tags: []
categories: ["编程语言"]
slug: "java"
draft: false
lastmod: "2017-07-13T21:17:19Z"
id: 2384400
url: "https://flyouwith.iteye.com/blog/2384400"
---

```

```

```
    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）指的第二个括号里