Matches a set of substrings in a string using a Trie