gpt4 book ai didi

java - 正则表达式 : Multiline check problem

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:59:44 24 4
gpt4 key购买 nike

你好,我对这个正则表达式有疑问

!
interface TenGigabitEthernet 1/49
description Uplink
no ip address
switchport
no shutdown
!
interface TenGigabitEthernet 1/50
no ip address
shutdown
!
interface TenGigabitEthernet 1/51
no ip address
shutdown
!

我试过这个正则表达式(接口(interface))((。\s.)+)但它不起作用,因为它匹配“接口(interface)”和文本的其余部分

我需要在第一组“接口(interface)”中捕获,在第二组中我需要所有直到第一次出现“!”例如:第一组:

interface

第二组:

TenGigabitEthernet 1/51
no ip address
shutdown

我该怎么做?

最佳答案

试试这个:

(interface)\s+([^!]+)

Here Is Demo

关于java - 正则表达式 : Multiline check problem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57176686/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com