reglist

Table of Contents

Prototype: reglist(list, regex)

Return type: boolean

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

This function can accept many types of data parameters.

Arguments:

  • list: string - CFEngine variable identifier or inline JSON - in the range: .*
  • regex: regular expression - 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.

History: The collecting function behavior was added in 3.9.

See also: getindices(), getvalues(), about collecting functions, and data documentation.