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?
Try this:
(interface)\s+([^!]+)
Here Is Demo
Use this:
(interface)\s*([^!]+) /g
The first group captures the hard-coded interface. The second group captures everything other than !, by skipping the leading whitespaces, if any. The global flag /g ensures all matches.
Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With