countclassesmatching

Table of Contents

Prototype: countclassesmatching(regex, tag1, tag2, ...)

Return type: int

Description: Count the number of defined classes matching regex.

This function matches classes, using an anchored regular expression that should match the whole line. The function returns the number of classes matched.

You can optionally restrict the search by tags, which you can list after the regular expression.

Example:

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

bundle agent example
{
  vars:
      # this is anchored, so you need .* to match multiple things
      "num" int => countclassesmatching("cfengine");
      "hardcount" int => countclassesmatching(".*", "hardclass");
  reports:
      "Found $(num) classes matching";
}

Output:

R: Found 1 classes matching

See also: classes defined via augments, classmatch(), classesmatching()