I have a list of approximately 300 words and a huge amount of text that I want to scan to find out how many times each word appears.
I am using re module from python:
for word in list_word: search = re.compile(r"""(\s|,)(%s).?(\s|,|\.|\))""" % word) occurrences = search.subn("", text)[1]
but I want to know if there is a more efficient or more elegant way to do this?
python regex
Mermoz
source share