I have a config file:
config line 1
....
config line n
router mk1
ip 10.1.1.2
deviceType t1
sub config line!
sub config line 2
!more sub config
!
!!!
more config lines
router mk2
ip 10.1.1.2
sub config line1
sub config line 2
deviceType t2
!
Each router block starts with the word router on a new line and ends with ! on a new line. A config file can contain many router blocks.Each sub-block begins with a single space.The lines in sub-block can be in any order.I want to select a block that contains a specific line for eg: deviceType t2.
So far I could identify all the router blocks with the following:
(?ms)^router mk.*?^!$
But I only need a block that contains the line deviceType t2