-1

命名.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";

以后可能会有更多的观点和专区。如何使用 RegExp 匹配 named.conf 文件中的单独视图

第 1 组:

查看局域网 { ... };

第 2 组:

查看无线 { ... };

谢谢你!

4

2 回答 2

0

假设 node.js 环境

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

var matches = namedConf.match(/view lan {(.*)};\s*view wireless{(.*)}/);
于 2017-06-27T04:55:25.957 回答
0

试试这个

var regexp = /(?:\n| )*view[\s\S\n\r ]+?(?=\n+ *view|$)/g
于 2017-06-27T05:29:55.340 回答