Java regex如何读取两个大括号之间的所有字符

Java regex如何读取两个大括号之间的所有字符,java,regex-group,Java,Regex Group,我正在读取日志文件,必须提取一行中的所有值,如下所示 > DE-055 LLL[136] > CHR(_*.....\............B........(............................................12345678.&..g..2%.$.'...3.`(..4.....5.!.6....7.s$...A......S..) 我试图使用regex来提取两个大括号()之间的数据。请告知我如何提取到目前为止,我已经尝试

我正在读取日志文件,必须提取一行中的所有值,如下所示

>    DE-055  LLL[136] 
> CHR(_*.....\............B........(............................................12345678.&..g..2%.$.'...3.`(..4.....5.!.6....7.s$...A......S..)
我试图使用regex来提取两个大括号()之间的数据。请告知我如何提取到目前为止,我已经尝试了不同的方法,但不能这样做

for (String s : incomingmessage) {
    // **DE-011  FXD[006]  CHR(008432)**
    pattern3 working 
    String pattern3 = "(DE\\W\\d*)(\\s*\\w*\\W*)(\\d*)(\\W*\\s*)  (\\w*)(\\()([\\w*\\s*]+)(\\))"; --> works when the value is like above,same code do not work for the below format 

    //DE-055  LLL[136]  CHR(_*.....\............B........(............................................12345678.&..g..2%.$.'...3.`(..4.....5.!.6....7.s$...A......S..)

    String pattern3 = "(DE\\W\\d*)(\\s*\\w*\\W*)(\\d*)(\\W*\\s*)(\\w*)(\\([.*?]\\))"; --> tried many times changing not able to get the regex which will work to get the values between the two braces even if it is some funny characters like the above

    Pattern p3 = Pattern.compile(pattern3);
    // Matcher m1 = p1.matcher(s);
    //Matcher m2 = p2.matcher(s);
    Matcher m3 = p3.matcher(s);

    while (m3.find()) {
        String fullvalue = m3.group(0);
        // String field = m3.group(1);
        //String length = m3.group(3);
        //String value = m3.group(7);
        System.out.println("m3.find() full value " + fullvalue);
        //System.out.println("m3.find() filed value " + field + "length " + length + "value" + value);
    }
}
我希望输出值如下所示,位于两个大括号()之间


如果您不希望使用嵌套大括号,则这将起作用:

String input = "sfasdf(sfsdfs76868)dslf()js98(sds),cn,";
String regex = "(?<=\\().*?(?=\\))";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);

while (matcher.find()) {
    System.out.println("Match: " + matcher.group(0));
}
第7组给出了我想要的输出。
谢谢所有试图帮助我的人。

你想要什么价值?我想我们需要更多关于每个正则表达式组将持有什么的信息。@Tyler我想提取两个()大括号。这是否有帮助->?@ElliottFrisch我已更新以显示我想要的值
String input = "sfasdf(sfsdfs76868)dslf()js98(sds),cn,";
String regex = "(?<=\\().*?(?=\\))";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);

while (matcher.find()) {
    System.out.println("Match: " + matcher.group(0));
}
Match: sfsdfs76868
Match: 
Match: sds
 String t = "DE-055  LLL[136]  CHR(_*.....\\............B........(............................................12345678.&..g..2%.$.'...3.`(..4.....5.!.6....7.s$...A......S..)";


String pattern3 = "(DE\\W\\d*)(\\s*\\w*\\W*)(\\d*)(\\W*\\s*)(\\w*)(\\()([\\W*?\\w*?\\s*?\\W*?]+)(\\))";

Output :

group 0 :   DE-055  LLL[136]  CHR(_*.....\............B........(............................................12345678.&..g..2%.$.'...3.`(..4.....5.!.6....7.s$...A......S..)
group 1 ;   DE-055
group 2 :     LLL[
group 3 :   136
group 4 :   ]  
group 5 :   CHR
group 6 :   (
group 7 :   _*.....\............B........(............................................12345678.&..g..2%.$.'...3.`(..4.....5.!.6....7.s$...A......S..
group 8 :   )