Regular Expression : Multiline check problem

Lukasz Flak :

Hello i have problem with this regexp

!
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
!

i tried this regexp (interface) ((.\s.)+) but it is not working becuse it match "interface" and the rest of text

I need to catch in first group "interface" and in the second i need all until first occur of "!" so for example: first group:

interface

second group:

TenGigabitEthernet 1/51
 no ip address
 shutdown

How i can do this?

user11116003 :

Try this:

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

Here Is Demo

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=126033&siteId=1