If there are a finite number of matching lines, this means that you can build a tree that, after reading from root to leaves, similar lines will occupy similar branches.
This is also called trie or Radix Tree .
For example, we can have the lines cat, coach, con, conch , as well as dark, dad, dank, do . Their trick may look like this:

Searching for one of the words in the tree will search for the tree, starting from the root. Bringing it to a leaf corresponds to a match with a seed. Regardless, each character in the string must correspond to one of its children. If this is not the case, you can stop the search (for example, you will not consider words starting with "g" or any words starting with "cu").
There are various algorithms for building a tree, as well as for finding it, as well as for changing it on the fly, but I thought that I would give a conceptual overview of the solution instead of the concrete one, since I do not know the best algorithm for it.
Conceptually, an algorithm that you could use to search in a tree would be associated with the idea of ββcreating a radix type of a fixed number of categories or values ββthat a character in a string could take at a given time.
This allows you to check a single word on a word-list . Since you are looking for this list of words as substrings of the input string, there will be more than that.
Edit:. As mentioned in other answers, the Aho-Corasick string matching algorithm is a complex algorithm for performing string matching, consisting of a trie with additional links for accepting βshortcutsβ through the tree and have a different search pattern to accompany this. (It is interesting to note that Alfred Aho is also the author of the popular compiler textbook Compilers: Principles, Methods and Tools, as well as the textbook on algorithms Design and Analysis of Computer Algorithms. He is also a former Bell member. Margaret J. Korasik too much public information about yourself.)