Matching /etc/resolv.conf with multiple nameserver lines

(imported comment written by jessewk)

Nice work Mee Wee. Ben beat me to an answer but I’ll post my version anyway.

if
not exists file "c:\etc\resolv.conf"
then
"Missing File"
else
if
number of unique values of parenthesized parts 1
whose
(
it = "10.10.1.24"
or
it = “123.1.45.100"
or
it =“123.1.45.101”
)
of first matches
(
case insensitive regex “\snameserver\s+((\d{1,3}.){3}\d{1,3})\s$”
)
of lines of file “c:\etc\resolv.conf” = 3
then
"PASS"
else
"FAIL”

In order to pass, the file must meet the following criteria:

  • All 3 IP required addresses must appear on a validly formated line
  • A validly formated line contains the text “nameserver” and an IP address which are separated by at least one whitespace character
  • A validly formated line may have leading or trailing whitespace
  • “nameserver” is case insenstive

Other nameserver lines are also allowed.

You may need to re-write it with a boost compatible regex. Search the forum for a few recent examples.