I have a config from Cisco ASA and I need to write a Python RegEx to capture everything that is in the object-groups and group them for further processing.
For example:
object-group network FTP
description FTP Access
network-object host BCD1
network-object host BCD2
object-group network NTP
description NTP Access
network-object host ABC1
network-object host ABC2
network-object host ABC3
object-group service sample_service tcp
description Ports 1 2 3
port-object range 80 81
port-object eq pop3
port-object eq imap4
port-object range 443 444
object-group service 8080 tcp
description Servers
The end result should be something like this:
Group 1: object-group network FTP
description FTP Access
network-object host BCD1
network-object host BCD2
Group 2: object-group network NTP
description NTP Access
network-object host ABC1
network-object host ABC2
etc.
As I said I am very bad at this, but I tried to come up with something but the result was horrible
(object-group\s[^!]*)object or (object-group[^!]*)
Both of them failed.