I have a list of patterns, and I have to find the pattern that best suits an input string.
d. H .:
[ 'AB1XXX', 'AB2XXX', 'ABXXXX-0080', 'BC1XXX', 'BC15XX' ]
I then get an input, d. H .:
AB1100, In this case, I expect the pattern
AB1XXX to be the best game.
However, if I get an entry
AB1100-0080 I expect
ABXXXX-0080 to be the best match for the given input.
I'm currently using a trie to find the matching pattern, but it does not really work for the given example, either because it can not find a match once it's arrived
Is there a known algorithm that I could implement, or should I stick to the implementation of a Levenshtein removal algorithm?