in reply to Glob best match?

Isn't that a standard problem in any filtering system, e.g. firewall rules? The standard solution is: list the more specific patterns first, then compare until you find the first match.

An automagic score for the specificity = precedence of a rule sounds cute. It would allow you to sort the rules by whatever pleases your eyes. But I suspect it would make debugging quite difficult, if your mental model of "specific" doesn't match exactly the possibly complicated algorithm.

So the mundane comparison from top to bottom is more tedious, but preferable for its predictability.