Negative Lookahead for the word

I hit my head against the wall on this one, I'm pretty new to regex and am a little out of the depths. I work with this network software, which does not allow matching several criteria in a field, but accepts regular expressions.

!(?!.*FastEthernet[0-24].[0-24]\.[0-250]) 

The software analyzes all the information until it meets the expressed criteria. So in my case, I want it to match ! if it is not followed by the auxiliary interface FastEthernet#/#.# , where # is any number.

Here are my details

 interface FastEthernet0/0 shutdown ! interface FastEthernet0/0.100 ip address 192.168.1.100 ! interface FastEthernet0/1 shutdown ! 
+4
source share
2 answers

This should do it:

 !(?!\s*interface FastEthernet\d/\d\.\d) 

See how it works on rubular

+2
source

I would use this:

 !(?!(.|\n|\r)*FastEthernet\d\d?\/\d\d?\.\d{1,3}) 

Seems to work for me .

+2
source

Source: https://habr.com/ru/post/1483379/


All Articles