in reply to Re^4: Regex to match a Cisco ACL
in thread Regex to match a Cisco ACL

Try the updated version. It uses the test data. There are still grammar bugs, because the last 3 fail, although the first 2 succeed.

I think you just need to get the grammar straight.

Replies are listed 'Best First'.
Re^6: Regex to match a Cisco ACL
by Anonymous Monk on May 22, 2011 at 17:14 UTC

    Thanks a bunch! Your updated code is indeed amazing, for its level of detail and re-usable tokens. It just gives a greater level of control and granularity over matching schema without having to resort to a code that looks like hieroglyphics.

    In hindsight, it was silly of me to ask again without checking the grammar. The last 3 rules failing is no surprise since the grammar doesn't account for it yet. I should produce a complete code soon, for the sake of others looking for the same stuff.

    May I ask whether it is possible to code multi-line grammar also in to regex? For e.g the below section of config file

    object-group network NOC-NC-NC1 network-object 192.162.137.0 255.255.255.0 network-object 192.162.146.0 255.255.255.0 object-group network NOC-NC-NC2 network-object 192.162.131.0 255.255.255.0 network-object 192.162.134.0 255.255.255.0

    Should be read into a hash of arrays as:

    $object_hash{"NOC-NC-NC1"} => ["192.162.137.0 255.255.255.0","192.162. +146.0 255.255.255.0"] $object_hash{"NOC-NC-NC2"} => ["192.162.131.0 255.255.255.0","192.162. +134.0 255.255.255.0"]