I'm trying to create a word count for a book (.txt file) and I'm trying to split each line into its separate words using this:
temp = re.split('[; |, |\*|\n| |\|:|.|’|"|&|#|$|(|)|]|//|'']', line)
However, this isn't working because every time I run the program, I have to add another delimiter to the list. This time I have to add '-' and '%'. I remember doing something similar in Java where I could specify a 'range' of delimiters and when I tried the same thing here, it didn't seem to work.
Is there any better way to do this and make sure I just get the word and nothing else?