Aho–Corasick string matching
Find every occurrence of every word on a list. You could read a story once and mark all the places where any of its characters’ names appear.
Build a tree of words. The words “cat” and “cats” share the path for their first three letters. This tree is called a trie. A check marks each place where a word ends.
Add suffix links. Suppose the list also contains “at”. The word “cat” ends in “at”, so a link leads from “cat” to “at”. This lets us find both words using letters we have already read.
Read one character and follow the arrow with that label. If there is no such arrow, follow a suffix link and try the same character again. If even the root has no arrow for it, read the next character. Record every word that ends at each position.