Regex 如何编写正则表达式,以便从此表达式的第三行获取输出

Regex 如何编写正则表达式,以便从此表达式的第三行获取输出,regex,regex-negation,regex-group,Regex,Regex Negation,Regex Group,名称 这是我的表情 我试过下面的正则表达式 ugui-9kleaf1 ugui-9kleaf2 Warning! ugui-9kleaf1's time is not in sync with the NTP Server. 我得到的输出是 r">.*[\r\n]?(.*)" 我想要实际产出 fabric-node-show format name, no-show-headers ugui-9kleaf1 ugui-9kleaf2 Warning! ugui-9kleaf1's ti

名称 这是我的表情

我试过下面的正则表达式

ugui-9kleaf1
ugui-9kleaf2
Warning! ugui-9kleaf1's time is not in sync with the NTP Server.
我得到的输出是

r">.*[\r\n]?(.*)"
我想要实际产出

fabric-node-show format name, no-show-headers
ugui-9kleaf1
ugui-9kleaf2
Warning! ugui-9kleaf1's time is not in sync with the NTP Server.
ugui-9kleaf1
ugui-9kleaf2
Warning! ugui-9kleaf1's time is not in sync with the NTP Server.
上面的正则表达式正在捕获(命令+输出),但我只需要实际输出

fabric-node-show format name, no-show-headers
ugui-9kleaf1
ugui-9kleaf2
Warning! ugui-9kleaf1's time is not in sync with the NTP Server.
ugui-9kleaf1
ugui-9kleaf2
Warning! ugui-9kleaf1's time is not in sync with the NTP Server.
我的正则表达式中的符号将跳过我的正则表达式的横幅

命令:结构节点显示格式名称,不显示标题
输出我得到的:
fabric节点显示格式名称,不显示标题
ugui-9kleaf1
ugui-9kleaf2
警告ugui-9kleaf1的时间与NTP服务器不同步。

输出我想要的

ugui-9kleaf1
ugui-9kleaf2
警告ugui-9kleaf1的时间与NTP服务器不同步。

上面的正则表达式正在捕获(命令+输出),但我只需要实际输出

fabric-node-show format name, no-show-headers
ugui-9kleaf1
ugui-9kleaf2
Warning! ugui-9kleaf1's time is not in sync with the NTP Server.
ugui-9kleaf1
ugui-9kleaf2
Warning! ugui-9kleaf1's time is not in sync with the NTP Server.
注意:命令可能会不时更改,因此我可以对值进行硬编码。所以我想要一个通用正则表达式,每次只捕获实际输出

我试过下面的正则表达式

Netvisor OS Command Line Interface 5.1
Connected to Switch ugui-9kleaf1; nvOS Identifier:0xb00163e; Ver: 5.1.0-5010014593
Warning! ugui-9kleaf1's time is not in sync with the NTP Server.
CLI (network-admin@ugui-9kleaf1) >
差不多就是这样了。正如我们在您的图像中看到的,匹配组1(绿色)包含所需输出的第一行,因此我们只需将匹配组1扩展到末尾。为此,我们可以使用标志
s
(点匹配换行符),但不能用于整个正则表达式(因为它不能应用于第一个
),只能用于组1,因此我们必须使用内联修饰符
(?s)


您能更清楚地了解您需要什么吗?请正确格式化/澄清您的问题。@BlackPearl我已添加图像,请查看itI,我希望测试织物作为我的输出。而且不显示标题并不是每次都不变的,它可能会根据需要而变化。在您的问题中,我看不到
测试结构
,而且仍然不清楚。请阅读