-1

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!

Anurak Jairak
  • 25
  • 1
  • 6
  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp – Matt Jun 27 '17 at 04:46

2 Answers2

0

Assuming node.js environment

var namedConf = fs.readFileSync('named.conf');

var matches = namedConf.match(/view lan {(.*)};\s*view wireless{(.*)}/);
shawon191
  • 1,945
  • 13
  • 28
0

Try this one

var regexp = /(?:\n| )*view[\s\S\n\r ]+?(?=\n+ *view|$)/g
Jan Ciołek
  • 1,796
  • 3
  • 17
  • 32