I am currently using a trie implementation from this stack overflow post:
Getting a list of words from a Trie
to return a list of words which match a given prefix. I'm then using regex to filter out the words which don't meet the entire specified pattern.
EX: if the pattern I'm searching for is: CH??S? and this is a subset of the dictionary which matches my initial prefix: {CHABAD, CHACHA, CHARIOT, CHATTED, CHEATER, CHOMSKY, CHANNEL CHAFED, CHAFER, CHAINS, CHAIRS, CHEESE, CHEESY CHRONO, CHUTES, CHISEL}
I would search the trie with 'CH' prefix and then filter out words which match my desired pattern of CH??S? (CHEESY, CHEESE, CHISEL) and return those.
I am wondering if there is a faster way to do this to avoid using the regex in the final step. I thought I could use a suffix tree (Ukkonen's suffix tree algorithm in plain English )or the boyer-moore algorithm but neither work because they search on suffixes not on patterns.