Krauss matching wildcards algorithm