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";
将来可能会有更多的观点和区域。如何使用RegExp匹配named.conf文件中的单独视图
第1组:
查看lan {...};
第2组:
查看无线{...};
谢谢!
答案 0 :(得分:0)
假设node.js环境
var namedConf = fs.readFileSync('named.conf');
var matches = namedConf.match(/view lan {(.*)};\s*view wireless{(.*)}/);
答案 1 :(得分:0)
试试这个
var regexp = /(?:\n| )*view[\s\S\n\r ]+?(?=\n+ *view|$)/g