For my own project, I have a .txt file containing 200k English words. I have a class called WordCross
(a game) which will search for words with certain letters as parameters, Suppose I have the letters A X D E L P. I want to return a list of English words with these letters. Now I have stumbled upon a problem. I want to use a regex and add the words that match to a "hits" list. However, I can't think of a way to create this regex.
Here is my current code:
import re
class WordCross:
def __init__(self, a,b,c,d,e,f):
file = open("english3.txt", "r")
hits = []
for words in file:
if words.lower() == re.search("a", words):
hits.append(words)
hits.sort()
print(hits)
test = WordCross("A", "B", "C", "D", "E", "F")
Any help will be appreciated! Kind regards, Douwe