Make sure wildcards are used properly

Wildcards are supposed to be surrounded by at least one character before
and one after.

If that's not the case, don't even try to match, just return an empty
vector.
Fix the build

In C++, functions must be defined before they are used.