reglist

Table of Contents

Prototype: reglist(list, regex)

Return type: boolean

Description: Returns whether the anchored regular expression regex matches any item in list.

Arguments:

  • list: string, in the range: @[(][a-zA-Z0-9_$(){}\[\].:]+[)]
  • regex: regular expression, in the range: .*

Example:

body common control
{
      bundlesequence => { "example" };
}

bundle agent example
{
  vars:

      "nameservers" slist => {
                               "128.39.89.10",
                               "128.39.74.16",
                               "192.168.1.103",
                               "10.132.51.66"
      };
  classes:

      "am_name_server" expression => reglist(@(nameservers), "127\.0\.0\.1");
  reports:
    am_name_server::
      "127.0.0.1 is currently set as a nameserver";
    !am_name_server::
      "127.0.0.1 is NOT currently set as a nameserver";
}

Output:

R: 127.0.0.1 is NOT currently set as a nameserver

In the example above, the IP address in $(sys.ipv4[eth0]) must be escaped, so that the (.) characters in the IP address are not interpreted as the regular expression "match any" characters.