Simplify regex/wildcard code