According to the documentation for the classesmatching() function, the "name" regex to be matched against is an unanchored regex.
This surprised me since CFEngine uses anchored regexes pretty much everywhere else.
Sure enough, the documentation is wrong (or the code is wrong, depending on your point of view):
This is a bug (either in the code or in the documentation).
Please note that according to Promise Theory, the documentation is the publication of the developers' intentions to the users of CFEngine. Also according to Promise Theory, when the published intention to the promisee does not match the observed behavior of the promiser, the result is reduced trust in that promiser by that promisee. So having the documentation inaccurate as a description of the behavior of CFEngine is a promise not kept by the developers and is factually more important to avoid than I believe is currently recognized!