Python - Fast count words in text from list of strings and that start with
问题 I know that similar questions have been asked several times, but my problem is a bit different and I am looking for a time-efficient solution, in Python. I have a set of words, some of them end with the "*" and some others don't: words = set(["apple", "cat*", "dog"]) I have to count their total occurrences in a text, considering that anything can go after an asterisk ("cat*" means all the words that start with "cat"). Search has to be case insensitive. Consider this example: text = "My cat