javascriptregexdnsbind9

How to match view by RegExp in Javascript


named.conf

options {
            listen-on port 53 { 127.0.0.1;};
            listen-on-v6 port 53 { ::1; };
            directory       "/var/named";
            dump-file "/var/named/data/cache_dump.db";
            statistics-file "/var/named/data/named_stats.txt";
            memstatistics-file "/var/named/data/named_mem_stats.txt";
    };

    view lan {
            match-clients {localhost;};

            zone "home.com" IN {
                   type master;
                   file "home.zone";
            };

            zone "test.com" IN {
                   type master;
                   file "test.com.zone";
            };

            zone    "demo.local" IN {
                    type master;
                    file "f.demo.local";
                    allow-update { none; };
            };
            zone    "1.168.192.in-addr.arpa" IN {
                    type master;
                    file "r.demo.local";
                    allow-update { none; };
            };
    };

    view wireless{
            match-clients {localhost;};

            zone    "home.com" IN {
                    type master;
                    file "home2.zone";
            };
    };

    include "/etc/rndc.key";

In the future may be more views and zone. How to use RegExp to match separate view in named.conf file

Group 1 :

view lan { ... };

Group 2 :

view wireless { ... };

Thank You!


Solution

  • Try this one

    var regexp = /(?:\n| )*view[\s\S\n\r ]+?(?=\n+ *view|$)/g