在Java正则表达式中剪切多行文本的一部分

我有以下文字:

(Some text before...)
display_name = lo
name = lo
is_up = 1
index = 1
is_virtual = 0
is_point_to_point = 0
MTU = 65536
hardware_address = (null)
parent = (null)
ip_counter = 2
inet6 addr = /::1
inet addr = /127.0.0.1
---------------End_of_text---------------------
(Some text after...)

我试图让这一切都在“ display_name = lo”和“ --------------- End_of_text -----------------”之间----”,则不包括“ display_name = lo”和“ End_of_text”。

我尝试运行以下命令:

String pattern = "^\\sdisplay_name = lo\\s+(.*)---------------Start_vpn_sig---------------------";

        Pattern r = Pattern.compile(pattern, Pattern.DOTALL);

        Matcher m = r.matcher(interfaceData);

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

没有匹配项,我想念什么?

评论