regarray

Table of Contents

Prototype: regarray(array, regex)

Return type: boolean

Description: Returns whether array contains elements matching the anchoredregular expression regex.

Arguments:

  • array: 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:

      "myarray[0]" string => "bla1";
      "myarray[1]" string => "bla2";
      "myarray[3]" string => "bla";

  classes:

      "ok" expression => regarray("myarray","b.*2");

  reports:

    ok::

      "Found in list";

    !ok::

      "Not found in list";

}

Output:

R: Found in list