Java正则表达式如何在括号中获取值

时间:2018-06-11 07:35:20

标签: java regex

 lineIdentifier:dasda creationDate:[08/06/2018 00:00:00 TO *] text: [dasda, lll]

使用regex我想仅返回creationDate

中的数据

08/06/2018 00:00:00*

这是我的模式,但不起作用

Pattern r = Pattern.compile("\\[(\\w*)\\]");
        Matcher m = r.matcher(result);

        if (m.find( )) {
            System.out.println("Found value: " + m.group(0) );
        }else {
            System.out.println("NO MATCH");
        }

知道我在做什么吗?

1 个答案:

答案 0 :(得分:2)

您可以尝试:

select